-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_root.go
More file actions
57 lines (51 loc) · 1.46 KB
/
cmd_root.go
File metadata and controls
57 lines (51 loc) · 1.46 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
package main
import (
"fmt"
"os"
"github.com/dotcommander/statusline/internal/configtui"
"github.com/dotcommander/statusline/internal/setupcmd"
"github.com/spf13/cobra"
)
func newRootCmd() *cobra.Command {
root := &cobra.Command{
Use: "statusline",
Short: "Two-line ANSI status bar for Claude Code",
Long: "statusline renders a Tokyo Night themed status bar from JSON piped on stdin.\n" +
"Run with no arguments and piped input to render. Use subcommands to configure.",
SilenceUsage: true,
SilenceErrors: true,
Run: func(cmd *cobra.Command, args []string) { _ = cmd.Help() },
}
root.AddCommand(newConfigCmd())
root.AddCommand(newSetupCmd())
return root
}
func newConfigCmd() *cobra.Command {
return &cobra.Command{
Use: "config",
Short: "Edit the statusline config in an interactive TUI",
RunE: func(cmd *cobra.Command, args []string) error { return configtui.Run() },
}
}
func newSetupCmd() *cobra.Command {
var local bool
c := &cobra.Command{
Use: "setup",
Short: "Configure Claude Code's settings.json to use statusline",
RunE: func(cmd *cobra.Command, args []string) error {
scope := "global"
if local {
scope = "local"
}
return setupcmd.Run(scope)
},
}
c.Flags().BoolVar(&local, "local", false, "configure .claude/settings.json in cwd instead of ~/.claude/settings.json")
return c
}
func executeRoot() {
if err := newRootCmd().Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}