-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6692280
commit cde122d
Showing
5 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
pkg/commands/install/homebrew_test.go → ...ommands/install/homebrew/homebrew_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package install | ||
package homebrew | ||
|
||
import ( | ||
"mycli/pkg/iostreams" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package install | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"mycli/pkg/commands/install/homebrew" | ||
"mycli/pkg/commands/install/xcode" | ||
"mycli/pkg/iostreams" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewInstallCmd(iostream *iostreams.IOStreams) *cobra.Command { | ||
cs := iostream.ColorScheme() | ||
installCmd := &cobra.Command{ | ||
Use: "install", | ||
Short: "Install software", | ||
Long: `All software installation commands.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { // No specific subcommand was provided | ||
fmt.Fprintln(iostream.Out, cs.GreenBold("Running all installation subcommands...")) | ||
for _, subcmd := range cmd.Commands() { | ||
fmt.Fprintf(iostream.Out, cs.Gray("Installing %s...\n"), subcmd.Use) | ||
if err := subcmd.RunE(subcmd, nil); err != nil { | ||
fmt.Fprintf(iostream.ErrOut, cs.Red("Failed to install %s: %v\n"), subcmd.Use, err) | ||
return err // or continue based on your policy | ||
} | ||
} | ||
fmt.Println("All installations completed successfully.") | ||
return nil | ||
} | ||
|
||
// If arguments are provided, let Cobra handle the command execution. | ||
return errors.New("subcommand required") | ||
}, | ||
} | ||
|
||
installCmd.AddCommand(xcode.NewCmdXcode(iostream)) | ||
installCmd.AddCommand(homebrew.NewCmdHomeBrew(iostream)) | ||
|
||
return installCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters