Simplify dictate language parsing and hoist help command rank#168
Merged
Conversation
Reuse core split_csv in dictate's _languages instead of re-inlining the CSV split-and-strip, and lift the help command-rank dict to a module constant so _OrderedGroup.list_commands stops rebuilding it on every --help/completion render.
…ions 13 flag-heavy commands each wrapped their run_<cmd>(opts, state, *, json_mode) body in a byte-identical 'lambda state, json_mode: run_<cmd>(opts, state, json_mode=json_mode)' to fit run_command's (state, json_mode) callable. Add a typed context.run_with_options(ctx, run_<cmd>, opts, json=...) adapter and route all 13 through it, so the seam lives in one place. opts/state are positional-only on the runner Protocol so a state-ignoring body can still name it _state.
…odes stream and agent both ran validate_output_flags(...) immediately followed by output.stream_output_modes(...) on the next line — the only two callers of validate_output_flags. Pair them in streaming.session.resolve_output_modes so the modes can't be resolved without first rejecting a contradictory -o/--json combination, and both commands call one helper.
app/init_exec._install_step hand-built the same skipped/failed/installed report rows that init/devserver.install_step (used by dev/share) already produces. Reuse it and keep only the init-specific launch decision. run_init raises Exit(1) on any failed step before reading will_launch, so the failed path no longer needs to special-case the flag — which also drops a # pragma: no mutate.
ffmpeg (mediafile), cloudflared (tunnel), the deploy CLIs (deploy), and the interactive picker's questionary (init_exec) each hand-constructed CLIError(error_type="missing_dependency", exit_code=1, ...). Route all four through a errors.missing_dependency() factory (mirrors auth_failure/ mutually_exclusive) so the error-type string can't drift across them.
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.
Reuse core split_csv in dictate's _languages instead of re-inlining the
CSV split-and-strip, and lift the help command-rank dict to a module
constant so _OrderedGroup.list_commands stops rebuilding it on every
--help/completion render.