Commit fc73ce7
authored
feat: add --version flag to root command (#15)
* feat: add --version flag to root command
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]>
* test: add proper version output validation with CheckFuncs
Why: Need to validate version output format supports both 'unknown' and version strings
Approach: Use CheckFuncs to validate output format while stripping variable content
Learned: CheckFunc provides better validation than regex for variable content
Next: Push and verify CI passes
Changes:
- Added strings import to data_for_test.go
- Added CheckFunc for version subcommand to validate format
- Added CheckFunc for --version flag to validate 'otel-cli version X' format
- Both CheckFuncs handle 'unknown' or multi-part version strings
- Use regex to strip content for checkOutput comparison
🤖 Claude <[email protected]>1 parent 6d810ec commit fc73ce7
2 files changed
+62
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
1373 | 1374 | | |
1374 | 1375 | | |
1375 | 1376 | | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
1376 | 1437 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
0 commit comments