Skip to content

fix: make --version exit with code 0 instead of 2#1125

Merged
jdalton merged 3 commits intov1.xfrom
fix/version-exit-code
Mar 20, 2026
Merged

fix: make --version exit with code 0 instead of 2#1125
jdalton merged 3 commits intov1.xfrom
fix/version-exit-code

Conversation

@mtorp
Copy link
Contributor

@mtorp mtorp commented Mar 20, 2026

Summary

  • socket --version now exits with code 0 instead of code 2. The --version flag was parsed but never explicitly handled at the root command level, causing it to fall through to showHelp(2). This broke Ansible automation that checks exit codes.
  • Fixed spurious "Received an unknown command: patch" error on every CLI invocation. The patch command was registered and public (hidden: false) but was commented out in the hardcoded command validation set.
  • Added patch to the help output under "Local tools" so it's discoverable via socket --help.
  • Bumped version to 1.1.75.

Test plan

  • node dist/cli.js --version prints version string and exits with code 0
  • No more "Received an unknown command: patch" in CLI output
  • Added unit test verifying --version outputs semver and exits 0
  • Existing --help and --dry-run tests pass with updated snapshots
  • Verify on Linux that socket --version exits cleanly in Ansible context

Note

Low Risk
Low risk: changes are limited to root CLI flag handling and help/command listings, plus test/snapshot updates, with no impact on auth or data processing.

Overview
Ensures socket --version is explicitly handled at the root level by printing INLINED_SOCKET_CLI_VERSION and exiting with code 0 instead of falling through to help/error behavior.

Makes the patch subcommand a first-class public command by adding it to the validated root command set and the --help output, removing prior test output sanitization that hid “unknown command: patch”.

Adds a unit test covering --version output/exit code and bumps the package version to 1.1.75.

Written by Cursor Bugbot for commit a3a357d. Configure here.

mtorp added 2 commits March 20, 2026 12:59
The --version flag was defined and parsed but never explicitly handled
at the root command level, causing it to fall through to showHelp with
exit code 2. This broke automation (e.g. Ansible) that checks the exit
code of `socket --version`.
The patch command was registered and unhidden but missing from the
hardcoded public commands validation set, causing a spurious
"Received an unknown command: patch" error on every CLI invocation.
Also removes the workaround in test utils that stripped this error.
@mtorp mtorp requested review from jdalton and mikolalysenko March 20, 2026 12:20
@mtorp mtorp marked this pull request as ready for review March 20, 2026 12:20
@jdalton jdalton enabled auto-merge (squash) March 20, 2026 14:54
@jdalton jdalton merged commit 5e9e01d into v1.x Mar 20, 2026
12 checks passed
@jdalton jdalton deleted the fix/version-exit-code branch March 20, 2026 14:56
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.

2 participants