You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Support machine-readable JSON help flag output - #305
This pull request introduces machine-readable JSON help output for the Fabric CLI, enabling scripts and automation to programmatically discover commands, arguments, and flags. It also refactors the help system to support offline help discovery, adds a versioned schema for help responses, and updates the documentation to describe these features. Additional improvements include changes to parser setup and interactive help, and a minor fix to the configuration file location.
Machine-readable JSON help and documentation:
Added support for machine-readable JSON help for root, group, and leaf commands, including offline help discovery and a versioned schema. (src/fabric_cli/core/fab_help.py, .changes/unreleased/added-20261026-103451.yaml) [1][2]
Updated documentation to describe how to use --output_format json for help and parameter discovery, including schema details and usage examples. (docs/essentials/output_format.md, docs/essentials/parameters.md) [1][2][3]
CLI parser and help system refactor:
Refactored CustomArgumentParser to intercept help requests and output JSON or text help as appropriate, supporting new help request resolution and output logic. (src/fabric_cli/core/fab_parser_setup.py) [1][2][3][4][5][6][7][8]
Updated interactive mode to use the new help system for help commands, ensuring consistent behavior across CLI modes. (src/fabric_cli/core/fab_interactive.py) [1][2]
Other improvements:
Changed the default configuration file location to ~/.config/fab/config.json and ensured the config directory is created with restricted permissions. (src/fabric_cli/core/fab_state_config.py) [1][2]
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
JSON help can report the wrong command, omit aliases, reject valid options, ignore caller-provided streams and legacy preferences, and advertise an unsupported REPL help alias.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Interactive help can crash on invalid configuration, a misleading mkdir note can lead to unintended folder creation, and generated usage and examples misrepresent valid commands.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Existing configuration directories may leave credentials accessible to other users, and JSON help misrepresents required flags, constraints, and defaults.
With an already initialized config, normal commands such as fab auth no longer tighten an existing ~/.config/fab directory to owner-only access. On POSIX, an older permissive directory can therefore leave pre-existing permissive credential files accessible to other users. Harden the directory in init_defaults(), while keeping the early offline help/version paths read-only.
JSON help reports incorrect default for --disable
src/fabric_cli/core/fab_help.py:215
For job run-update --disable, argparse's store_false action has the internal default True, so JSON help advertises --disable with "default": true even though omitting the flag does not disable the schedule. Consumers can therefore infer the opposite of the actual default behavior. Omit this internal default, or represent the flag's presence semantics explicitly.
Document ln flag exclusivity and type constraint
src/fabric_cli/core/fab_help.py:265
JSON help for ln marks both --target and --input optional without stating that exactly one is required, so consumers can construct commands that runtime validation rejects. Add parser-owned notes for that constraint and for the restriction that --target requires --type oneLake.
Generated usage omits required flags
src/fabric_cli/core/fab_help.py:281
This usage string makes every flag optional, including flags that the parser requires. For example, JSON help for import advertises fab import <path> [flags], but that invocation always fails without --input; table load has the same problem with --file. Include required flags in the generated usage so clients can construct a valid invocation.
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
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.
📥 Pull Request
✨ Description of new changes
This pull request introduces machine-readable JSON help output for the Fabric CLI, enabling scripts and automation to programmatically discover commands, arguments, and flags. It also refactors the help system to support offline help discovery, adds a versioned schema for help responses, and updates the documentation to describe these features. Additional improvements include changes to parser setup and interactive help, and a minor fix to the configuration file location.
Machine-readable JSON help and documentation:
src/fabric_cli/core/fab_help.py,.changes/unreleased/added-20261026-103451.yaml) [1] [2]--output_format jsonfor help and parameter discovery, including schema details and usage examples. (docs/essentials/output_format.md,docs/essentials/parameters.md) [1] [2] [3]CLI parser and help system refactor:
CustomArgumentParserto intercept help requests and output JSON or text help as appropriate, supporting new help request resolution and output logic. (src/fabric_cli/core/fab_parser_setup.py) [1] [2] [3] [4] [5] [6] [7] [8]src/fabric_cli/core/fab_interactive.py) [1] [2]Other improvements:
~/.config/fab/config.jsonand ensured the config directory is created with restricted permissions. (src/fabric_cli/core/fab_state_config.py) [1] [2]Link to spec
Json structure