From cdb6faf024fbd966cb3f8756b211f79d43771b0b Mon Sep 17 00:00:00 2001 From: AnnatarHe Date: Thu, 25 Dec 2025 18:12:22 +0800 Subject: [PATCH] refactor(cli): rename init command to auth and add new init orchestrator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the existing `init` command to `auth` for clearer naming, and create a new `init` command that orchestrates full setup by calling auth, hooks install, and daemon install in sequence. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cmd/cli/main.go | 1 + commands/auth.go | 4 ++-- commands/init.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 commands/init.go diff --git a/cmd/cli/main.go b/cmd/cli/main.go index d529ef5..3a2a511 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -93,6 +93,7 @@ func main() { } app.Commands = []*cli.Command{ + commands.InitCommand, commands.AuthCommand, commands.TrackCommand, commands.GCCommand, diff --git a/commands/auth.go b/commands/auth.go index 224c649..65493e1 100644 --- a/commands/auth.go +++ b/commands/auth.go @@ -17,8 +17,8 @@ import ( ) var AuthCommand *cli.Command = &cli.Command{ - Name: "init", - Usage: "init your shelltime.xyz config", + Name: "auth", + Usage: "Authenticate with shelltime.xyz", Flags: []cli.Flag{ &cli.StringFlag{ Name: "token", diff --git a/commands/init.go b/commands/init.go new file mode 100644 index 0000000..fac4657 --- /dev/null +++ b/commands/init.go @@ -0,0 +1,42 @@ +package commands + +import ( + "github.com/gookit/color" + "github.com/urfave/cli/v2" +) + +var InitCommand *cli.Command = &cli.Command{ + Name: "init", + Usage: "Initialize shelltime: authenticate, install hooks, and start daemon", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "token", + Aliases: []string{"t"}, + Usage: "Authentication token", + Required: false, + }, + }, + Action: commandInit, +} + +func commandInit(c *cli.Context) error { + color.Yellow.Println("Initializing ShellTime...") + + // Step 1: Authenticate + if err := commandAuth(c); err != nil { + return err + } + + // Step 2: Install shell hooks + if err := commandHooksInstall(c); err != nil { + return err + } + + // Step 3: Install daemon service + if err := commandDaemonInstall(c); err != nil { + return err + } + + color.Green.Println("ShellTime is fully initialized and ready to use!") + return nil +}