-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork
More file actions
101 lines (93 loc) · 2.5 KB
/
work
File metadata and controls
101 lines (93 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# Refocus Shell - Main Dispatcher Script
# Copyright (c) 2025 PeGa
# Licensed under the GNU General Public License v3
# Exit on any error for critical safety
set -e
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Function to get the command directory
get_command_dir() {
# First check installed location
if [[ -d "$HOME/.local/focus/commands" ]]; then
echo "$HOME/.local/focus/commands"
else
# Fallback to source directory
echo "$SCRIPT_DIR/commands"
fi
}
# Function to execute a subcommand
execute_subcommand() {
local subcommand="$1"
shift
local command_dir
command_dir=$(get_command_dir)
local command_file="$command_dir/focus-$subcommand.sh"
if [[ -f "$command_file" ]]; then
# Source the libraries first
if [[ -f "$HOME/.local/focus/lib/focus-db.sh" ]]; then
source "$HOME/.local/focus/lib/focus-db.sh"
source "$HOME/.local/focus/lib/focus-utils.sh"
else
source "$SCRIPT_DIR/lib/focus-db.sh"
source "$SCRIPT_DIR/lib/focus-utils.sh"
fi
# Execute the subcommand
"$command_file" "$@"
else
echo "❌ Unknown subcommand: $subcommand"
echo "Run 'focus help' for available commands"
exit 1
fi
}
# Main command dispatch
case "${1:-}" in
"on")
execute_subcommand "on" "${@:2}"
;;
"off")
execute_subcommand "off" "${@:2}"
;;
"status")
execute_subcommand "status" "${@:2}"
;;
"enable")
execute_subcommand "enable" "${@:2}"
;;
"disable")
execute_subcommand "disable" "${@:2}"
;;
"reset")
execute_subcommand "reset" "${@:2}"
;;
"init")
execute_subcommand "init" "${@:2}"
;;
"export")
execute_subcommand "export" "${@:2}"
;;
"import")
execute_subcommand "import" "${@:2}"
;;
"past")
execute_subcommand "past" "${@:2}"
;;
"report")
execute_subcommand "report" "${@:2}"
;;
"test-nudge")
execute_subcommand "test-nudge" "${@:2}"
;;
"config")
execute_subcommand "config" "${@:2}"
;;
"help"|"--help"|"-h"|"")
execute_subcommand "help" "${@:2}"
;;
*)
echo "❌ Unknown command: $1"
echo "Run 'focus help' for available commands"
exit 1
;;
esac
bash -c exit && exit