-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfocus
More file actions
executable file
·110 lines (103 loc) · 2.62 KB
/
focus
File metadata and controls
executable file
·110 lines (103 loc) · 2.62 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
102
103
104
105
106
107
108
109
110
#!/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/refocus/commands" ]]; then
echo "$HOME/.local/refocus/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
# Execute the subcommand (it will handle its own bootstrap)
"$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}"
;;
"pause")
execute_subcommand "pause" "${@:2}"
;;
"continue")
execute_subcommand "continue" "${@: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}"
;;
"notes")
execute_subcommand "notes" "${@:2}"
;;
"nudge")
execute_subcommand "nudge" "${@:2}"
;;
"description")
execute_subcommand "description" "${@:2}"
;;
"report")
execute_subcommand "report" "${@:2}"
;;
"test-nudge")
execute_subcommand "test-nudge" "${@:2}"
;;
"config")
execute_subcommand "config" "${@:2}"
;;
"diagnose")
execute_subcommand "diagnose" "${@: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