Skip to content

Commit

Permalink
implement the pico-init comamnd
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed Jul 9, 2023
1 parent 49098aa commit 432f0da
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions cmd/pico.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,20 @@ func NewPicoCommand() []*cmdr.Command {
vso.Trans("shell.description"),
handleFunc(),
)

initCmd := cmdr.NewCommand(
"init",
"pico-init",
vso.Trans("init.description"),
vso.Trans("init.description"),
handleFunc(),
picoInit,
)
initCmd.WithBoolFlag(
cmdr.NewBoolFlag(
"force",
"f",
vso.Trans("init.force"),
false,
),
)

return []*cmdr.Command{
Expand All @@ -82,3 +91,20 @@ func NewPicoCommand() []*cmdr.Command {
initCmd,
}
}

func picoInit(cmd *cobra.Command, args []string) error {
force, _ := cmd.Flags().GetBool("force")

if core.PicoExists() && !force {
cmdr.Error.Println("The Pico subsystem is already initialized. Use the --force flag to force the initialization.")
return nil
}

err := core.PicoInit()
if err != nil {
return err
}

cmdr.Success.Println("The Pico subsystem has been initialized successfully.")
return nil
}

0 comments on commit 432f0da

Please sign in to comment.