Skip to content
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

Suppliment bundle location with positional arg #168

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func ServeCmd() *cobra.Command {
Use: "serve",
Short: "Start API server",
Long: `Start API server`,
Args: cobra.MaximumNArgs(1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this make the positional parameter mandatory, meaning that sbctl shell -s support-bundle.tar.gz stops working?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, ExactArgs or MinimumNArgs would make the argument mandatory. MaximumNArgs was chosen because it allows for 0 arguments.

The serve and shell subcommands currently accept no arguments so the existing behavior remains the untouched.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM. I tested your PR and it works as intended.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yer, I misread Max as Min and jumped the gun :D

SilenceUsage: true,
SilenceErrors: false,
PreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -50,6 +51,9 @@ func ServeCmd() *cobra.Command {

// This only works with generated config, so let's make sure we don't mess up user's real files.
bundleLocation := v.GetString("support-bundle-location")
if len(args) > 0 && args[0] != "" {
bundleLocation = args[0]
}
if bundleLocation == "" {
return errors.New("support-bundle-location is required")
}
Expand Down
4 changes: 4 additions & 0 deletions cli/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func ShellCmd() *cobra.Command {
Use: "shell",
Short: "Start interractive shell",
Long: `Start interractive shell`,
Args: cobra.MaximumNArgs(1),
SilenceUsage: true,
SilenceErrors: false,
PreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -61,6 +62,9 @@ func ShellCmd() *cobra.Command {

// This only works with generated config, so let's make sure we don't mess up user's real files.
bundleLocation := v.GetString("support-bundle-location")
if len(args) > 0 && args[0] != "" {
bundleLocation = args[0]
}
if bundleLocation == "" {
return errors.New("support-bundle-location is required")
}
Expand Down
Loading