[IMP] cli: Add program description and rewrite --help for the deployv-only CLI - #239
Merged
Merged
Conversation
Using --build-env-args with multiple values in a single flag, e.g.:
--build-env-args VIM_INSTALL ZSH_INSTALL
silently discarded every value but the first one, because the parsing
only extracted item[0] from each appended nargs list. This is exactly
the usage documented in the README, so it was broken as documented.
Flatten the nested lists instead, so both the repeated-flag form and
the multi-value form generate every ENV line in the Dockerfile.
Every git command executed was printed twice to stdout with bare print() calls, polluting the tool output with debug noise that could not be silenced. Use logging.debug() instead, so it stays hidden by default and can be enabled when actually debugging.
The 20-run.sh template already hardcodes -ditP in the docker run command, so the -itP included in the --run-extra-args default value produced 'docker run -itP ... -ditP ...' with every flag repeated. Docker tolerates the repetition, but it is confusing when reading the generated script and the --help default. Keep only the LANG export in the default value.
The --help output had terse descriptions with no examples nor default values, making the tool hard to discover without reading the source. - Add a program description explaining what the tool actually does today: generate a Dockerfile and helper scripts from the deployv image of a repository based on its variables.sh file. - Add an epilog with usage examples and the TRAVIS2DOCKER_ROOT_PATH environment variable. - Document the default value of every parameter in its help text. - Fix the --build-env-args help: it documented 'ARG NAME' and 'ENV NAME=$NAME' lines, but the deployv template actually generates 'ENV NAME=TRUE' lines used to enable optional installation steps such as VIM_INSTALL and ZSH_INSTALL. - Clarify that -ditP is already hardcoded in 20-run.sh so it does not need to be passed via --run-extra-args.
The tool prefers ~/.ssh/id_ed25519.pub for the container's authorized_keys and warns that RSA keys are deprecated, but the README only documented how to remove the passphrase from RSA keys. Document the Ed25519 flow first and keep the RSA one as legacy. Also clarify that https urls are supported for public repositories and remove trailing whitespace.
Configure logging.basicConfig at DEBUG level in the CLI entry point so the _logger.debug messages of git_run are printed, and replace the remaining print/stdout.write calls of cli.py and travis2docker.py with the standard logger (warning for deprecations, info for regular output). docker_helper/build.py keeps its prints on purpose, as stated by its 'No plan to use logging here' note.
Add a logging_colored module based on the pre-commit-vauxoo one, with a ColoredFormatter that colorizes the levelname with ANSI sequences, and use it in the CLI handler. Migrate the docker_helper/build.py prints to its own standalone logger (it is copied into the image and run with python3 -c 'import build'). Since no print calls remain, remove the RUFF_DISABLE_CHECKS='print' override from variables.sh and the print-used pylint disables.
moylop260
force-pushed
the
main-cli-help-moy
branch
from
August 7, 2026 22:32
086c44d to
12f8e62
Compare
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.
Running
travisfile2dockerfile --helpshowed no description at all of what thetool does, and the per-option help texts still talked in terms of the old
.travis.ymlworkflow. After the deployv-only refactor (#238) the tool doessomething quite different from what its name suggests, so the
--helpoutputis the first place a new user looks.
This PR makes the CLI self-documenting:
prog,descriptionandepilogto theArgumentParserexplaining whatt2d does today: clone the repository, read the
variables.shof the deployvimage at the given revision, and generate a
Dockerfileplus10-build.shand
20-run.shscripts to build the image and run a development container.The epilog includes real usage examples (branch,
pull/#,--docker-image,--no-clone) and documents theTRAVIS2DOCKER_ROOT_PATHenvironmentvariable, using
RawDescriptionHelpFormatterto keep the formatting.--helptext for clarity, stating the default value of eachoption and marking the no-op options (
--exclude-after-success,--travis-yml-path,--runs-at-the-end-script,--deployv) explicitly asdeprecated/ignored.
--build-env-argsto flatten all the values when the option is repeated,instead of only taking the first group.
-itPfrom the default--run-extra-argssince20-run.shalreadyhardcodes
-ditP, which madedocker runreceive the flags twice.printcalls ofgit_run.pywith standardlogging.repository URL formats.
remaining
print/stdout.writecalls ofcli.pyandtravis2docker.pyto the standard logger, so the
git_rundebug messages are printed too.logging_coloredmodule based on thepre-commit-vauxoo one (ANSI-colored levelname per level), migrate the last
printcalls ofdocker_helper/build.pyto a standalone logger, and dropthe
RUFF_DISABLE_CHECKS="print"override fromvariables.shalong withthe
print-usedpylint disables now that no print calls remain.