feat(cli,mcp): accept -h and -V/--version - #200
Merged
Merged
Conversation
- osw: -h is an alias of --help on every command - osw and osw-mcp: -V/--version print one line and exit 0 - the line names the version, package location and Python version - neither flag needs configuration, credentials or network - osw-mcp rejects an unknown or abbreviated argument with exit 2
Contributor
Release previewMerging this PR would release v2.7.0 (current: Changelog preview (truncated)## v2.7.0 (2026-09-22)
### Features
- **cli,mcp**: Accept -h and -V/--version
([`39c603e`](https://github.com/OpenSemanticLab/osw-python/commit/39c603e4b0ea95e49198d1b9d899d9497a61ec5a))
### Testing
- **cli**: Check -h on every command, not three sample paths
([`8a65754`](https://github.com/OpenSemanticLab/osw-python/commit/8a65754c04565e8009ac7f0ff29713ac9b937ac0))
Preview via python-semantic-release and conventional commits. |
- the commands are generated from the operation registry - walk the whole click tree and require exit 0 for each
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.
Closes #199
Changes
osw:-his an alias of--helpon the root and on every subcommand and group.--helpstays the first help option name, so click's usage hint still reads "Try '... --help' for help.".osw --version/-V: an eager root option that prints one line and exits 0 before the root callback runs. It needs no configuration, credentials or network, and builds noContext.osw-mcpnow parses its arguments with argparse (main(argv=None), readingsys.argv[1:]):-h/--helpprints the help and exits 0,-V/--versionprints the version line and returns,--vers(allow_abbrev=False), is a usage error with exit code 2.All three happen before the server is built, so none of them needs credentials. With no argument the server starts as before.
osw.service.version.version_line(prog)builds the line for both commands:--versionand-Vare added to_ROOT_OPTIONS, soosw entity --versionsays the flag belongs before the command.-h/--helpare not added, because they are valid after a command.osw-mcphelp text keeps its documentation URL on one line at any terminal width, and points todocs/tools/mcp.mdon GitHub.docs/tools/cli.mdanddocs/tools/mcp.mddescribe the new flags.Rationale
-hand-Vare the usual short forms.-vis already--verboseinosw.-His not added: other tools use it for other things (curl -H,grep -H,ls -H).v2.4.0-60-gbd849e9reports2.4.0. The location shows that the code is a checkout.pip --versionprints the same kind of line.build_type: workflowand serves an old mkdocs upload instead of thegh-pagesbranch thatmikedeploys to, so no current docs page is reachable there, including/dev/and/latest/.Behaviour change
osw-mcpused to ignore every argument and start the server. It now rejects an unknown argument with exit code 2. An MCP client configuration that passes a stray argument will fail to start instead of starting and ignoring it.Tests
tests/test_cli.py:-hon the root, a group and a leaf command;--versionand-Vcompared exactly with a line built in the test, with everyOSW_*variable removed;--versionbuilds noContext;--version/-Vafter a command gives the root-option hint; the usage hint names--help; the version callback writes UTF-8 to a cp1252 stdout.tests/test_mcp_server.py:-V,--version,-h, an unknown and an abbreviated argument, each without building the server;main()with no argument readssys.argv; the help text is ASCII and keeps the URL on one line at 60, 90 and 132 columns. Existing calls toserver.main()now pass[], because under pytestsys.argvholds pytest's own arguments.tests/test_osw_entry.py:osw --versionthrough the console script prints only the version line and no import notice.Local: 704 passed, 90 passed with
GITHUB_ACTIONS=truefor the CLI, MCP and entry-point tests, andmake checkpassed.