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 +}