Skip to content

Commit efbf00a

Browse files
authored
fix: remove root run and requires launch command to start daemon (#12)
1 parent a493743 commit efbf00a

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,31 @@ cd govim
4848
just build
4949

5050
# Run
51-
./bin/govim
51+
./bin/govim launch
52+
```
53+
54+
### CLI Commands
55+
56+
```bash
57+
# Launch the daemon
58+
govim launch
59+
60+
# Launch the daemon with custom config
61+
govim launch --config /path/to/config.toml
62+
63+
# Show help and available commands
64+
govim help
65+
66+
# Generate shell completions (bash/zsh/fish/powershell)
67+
govim completion [bash|zsh|fish|powershell]
68+
69+
# Show version information
70+
govim version
71+
72+
# Control the daemon
73+
govim start # Start navigation features
74+
govim stop # Stop navigation features
75+
govim status # Show current status
5276
```
5377

5478
### Required Permissions
@@ -370,7 +394,6 @@ To enable hints in Chrome:
370394
]
371395
```
372396

373-
374397
## Development
375398

376399
### Building

cmd/govim/main.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,30 +1020,8 @@ func main() {
10201020
// Set the launch function for CLI
10211021
cli.LaunchFunc = LaunchDaemon
10221022

1023-
// Check if this is a CLI command (subcommand)
1024-
if len(os.Args) > 1 {
1025-
arg := os.Args[1]
1026-
// These commands use CLI/IPC
1027-
if arg == "launch" || arg == "start" || arg == "stop" || arg == "hints" ||
1028-
arg == "scroll" || arg == "hints_action" || arg == "idle" || arg == "status" ||
1029-
arg == "help" || arg == "--help" || arg == "-h" || arg == "--version" || arg == "-v" {
1030-
cli.Execute()
1031-
return
1032-
}
1033-
// If it's just --config, continue to daemon mode
1034-
}
1035-
1036-
// Extract config path from args if provided
1037-
configPath := ""
1038-
for i, arg := range os.Args {
1039-
if arg == "--config" && i+1 < len(os.Args) {
1040-
configPath = os.Args[i+1]
1041-
break
1042-
}
1043-
}
1044-
1045-
// Launch daemon directly (root command without subcommand)
1046-
LaunchDaemon(configPath)
1023+
// Let cobra handle all command parsing
1024+
cli.Execute()
10471025
}
10481026

10491027
// LaunchDaemon is called by the CLI to launch the daemon

internal/cli/root.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ var rootCmd = &cobra.Command{
2626
Long: `GoVim is a keyboard-driven navigation tool for macOS that provides
2727
vim-like navigation capabilities across all applications using accessibility APIs.`,
2828
Version: Version,
29-
Run: func(cmd *cobra.Command, args []string) {
30-
// Root command launches the program
31-
launchProgram(configPath)
29+
RunE: func(cmd *cobra.Command, args []string) error {
30+
return cmd.Help()
3231
},
3332
}
3433

0 commit comments

Comments
 (0)