Skip to content

Accept --version as an alias for the version subcommand

Placeholder ppxd requested to merge feat/tentacle-version-flag-alias into main

Summary

  • CommandResolver treats any leading dash as a configuration flag and routes it to RunCommand, so squid-tentacle --version started the agent instead of reporting a version. A caller that pipes the output then waits on a process that never exits — that cost a production hang in 1.4.1/1.4.2, deploy/packaging/after-install.sh carries three layers of defence about it, and the one workflow that forgot had been failing daily on main (#481).
  • Route --version the way help flags are already routed: checked before the dash-means-config rule, via a new CommandResolver.IsVersionFlag.
  • -v is deliberately not claimed. It is already pinned as an ordinary config flag by the existing Resolve_LeadingConfigFlag_DefaultsToRun_AndPassesAllArgsThrough theory, and it means "verbose" in most CLIs — taking it would be exactly the breaking change this PR avoids.
  • A command set with no VersionCommand registered falls through to today's behaviour, so the alias is additive and can never introduce a new failure mode.

Nothing depends on the old behaviour: the only reference to squid-tentacle --version anywhere in the repo was the (already corrected) assertion in verify-linux-packages.yml.

Test plan

  • Unit: --version / --VERSION route to VersionCommand; the bare version verb still routes there; unregistered-VersionCommand falls back to run; IsVersionFlag rejects -v, -V, version, empty and null — 30/30 in CommandResolverTests
  • Mutation, three directions, each fails tests: drop the route (2 fail), also claim -v (2 fail), route to RunCommand instead of VersionCommand (3 fail)
  • Real binary: version, --version and --VERSION all print the version and exit immediately; -v still starts the agent, confirming the config-flag contract is untouched
  • Full Squid.Tentacle.Tests suite — remaining local failures are all StartScript_* tripping DiskSpaceChecker on a host below its 10% free-space floor, unrelated to this change
  • CI confirmation

Notes

after-install.sh keeps the bare version verb on purpose and this PR does not change it: mid-upgrade it can probe a not-yet-replaced older binary, for which only the verb has ever worked. Recorded in VersionCommand's remarks.

Merge request reports

Loading