fix: make --version exit with code 0 instead of 2#1125
Merged
Conversation
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.
jdalton
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
socket --versionnow exits with code 0 instead of code 2. The--versionflag was parsed but never explicitly handled at the root command level, causing it to fall through toshowHelp(2). This broke Ansible automation that checks exit codes.patchcommand was registered and public (hidden: false) but was commented out in the hardcoded command validation set.patchto the help output under "Local tools" so it's discoverable viasocket --help.Test plan
node dist/cli.js --versionprints version string and exits with code 0--versionoutputs semver and exits 0--helpand--dry-runtests pass with updated snapshotssocket --versionexits cleanly in Ansible contextNote
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 --versionis explicitly handled at the root level by printingINLINED_SOCKET_CLI_VERSIONand exiting with code0instead of falling through to help/error behavior.Makes the
patchsubcommand a first-class public command by adding it to the validated root command set and the--helpoutput, removing prior test output sanitization that hid “unknown command: patch”.Adds a unit test covering
--versionoutput/exit code and bumps the package version to1.1.75.Written by Cursor Bugbot for commit a3a357d. Configure here.