Skip to content

Commit

Permalink
fix(version): properly validate command line arguments (#65)
Browse files Browse the repository at this point in the history
Exit with diagnostic message and code 1 if there are command line
arguments. Doing this just for correctness.
  • Loading branch information
bassosimone authored Dec 23, 2024
1 parent c7cea98 commit 5b265e9
Showing 1 changed file with 9 additions and 1 deletion.
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
}

0 comments on commit 5b265e9

Please sign in to comment.