Skip to content

Conversation

@tobert
Copy link
Owner

@tobert tobert commented Nov 9, 2025

Summary

Adds support for flag (and short form) to otel-cli, following standard CLI conventions.

Changes

  • ✅ Set in to enable Cobra's built-in version flag
  • ✅ Added functional tests for both subcommand and flag
  • ✅ Tests verify output format and exit code 0
  • ✅ All tests pass

Testing

Functional tests added:

  1. version subcommand - tests works correctly
  2. --version flag - tests works correctly

Both test that:

  • Output contains version information
  • Exit code is 0

Manual testing:

$ ./otel-cli --version
otel-cli version 0.6.0-test test123 2025-11-09

$ ./otel-cli -v
otel-cli version 0.6.0-test test123 2025-11-09

$ ./otel-cli version
0.6.0-test test123 2025-11-09

Related

Fixes #9

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

Why: Users expect --version flag as standard CLI pattern (issue #9)
Approach: Set rootCmd.Version in createRootCmd, add functional tests
Learned: Cobra auto-adds -v/--version when Version field is set
Next: Create PR and close issue

Changes:
- Added rootCmd.Version = config.Version in createRootCmd()
- Added functional tests for both 'version' subcommand and '--version' flag
- Tests verify output format and exit code
- All tests pass

Fixes #9

🤖 Claude <[email protected]>
Copilot AI review requested due to automatic review settings November 9, 2025 20:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds standard --version flag support to otel-cli, complementing the existing version subcommand. The implementation leverages Cobra's built-in version functionality by setting the Version field on the root command.

Key changes:

  • Enabled Cobra's built-in --version flag by setting rootCmd.Version
  • Added functional tests for both version subcommand and --version flag

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
otelcli/root.go Sets rootCmd.Version to enable built-in --version flag support
data_for_test.go Adds test cases validating both version subcommand and --version flag behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tobert tobert closed this Nov 9, 2025
@tobert tobert deleted the add-version-flag branch November 9, 2025 20:28
@tobert tobert restored the add-version-flag branch November 9, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add command to print version

2 participants