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

fix(version): properly validate command line arguments #65

Merged
merged 1 commit into from
Dec 23, 2024
Merged
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
10 changes: 9 additions & 1 deletion pkg/cli/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ func (cmd command) Main(ctx context.Context, env cliutils.Environment, argv ...s
return cmd.Help(env, argv...)
}

// 2. print the version
// 2. ensure there are no command line arguments
if len(argv) > 1 {
err := fmt.Errorf("expected no positional arguments")
fmt.Fprintf(env.Stderr(), "rbmk version: %s\n", err)
fmt.Fprintf(env.Stderr(), "Run `rbmk version --help` for usage.\n")
return err
}

// 3. print the version
fmt.Fprintln(env.Stdout(), Version)
return nil
}
Loading