-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(cli): rename init command to auth and add new init orchestrator #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
|
Comment on lines
+22
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better observability and error diagnosis, I suggest two improvements to the
func commandInit(c *cli.Context) error {
ctx, span := commandTracer.Start(c.Context, "init")
defer span.End()
c.Context = ctx
color.Yellow.Println("Initializing ShellTime...")
// Step 1: Authenticate
if err := commandAuth(c); err != nil {
return fmt.Errorf("authentication failed: %w", err)
}
// Step 2: Install shell hooks
if err := commandHooksInstall(c); err != nil {
return fmt.Errorf("shell hooks installation failed: %w", err)
}
// Step 3: Install daemon service
if err := commandDaemonInstall(c); err != nil {
return fmt.Errorf("daemon service installation failed: %w", err)
}
color.Green.Println("ShellTime is fully initialized and ready to use!")
return nil
} |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support error wrapping in
commandInit, thefmtpackage needs to be imported. This will be used to provide more descriptive error messages if any of the initialization steps fail.