diff --git a/data_for_test.go b/data_for_test.go index 8250e15..4cc86bf 100644 --- a/data_for_test.go +++ b/data_for_test.go @@ -1373,4 +1373,29 @@ var suites = []FixtureSuite{ }, }, }, + // version flag tests + { + { + Name: "version subcommand", + Config: FixtureConfig{ + CliArgs: []string{"version"}, + }, + Expect: Results{ + CliOutput: "\n", + CliOutputRe: regexp.MustCompile(`\S+`), + ExitCode: 0, + }, + }, + { + Name: "--version flag", + Config: FixtureConfig{ + CliArgs: []string{"--version"}, + }, + Expect: Results{ + CliOutput: "\n", + CliOutputRe: regexp.MustCompile(`otel-cli version \S+`), + ExitCode: 0, + }, + }, + }, } diff --git a/otelcli/root.go b/otelcli/root.go index db8ba6c..7b3830a 100644 --- a/otelcli/root.go +++ b/otelcli/root.go @@ -59,6 +59,7 @@ func createRootCmd(config *Config) *cobra.Command { cobra.EnableCommandSorting = false rootCmd.Flags().SortFlags = false + rootCmd.Version = config.Version Diag.NumArgs = len(os.Args) - 1 Diag.CliArgs = []string{}