feat: add commands to list the command tree for easier discovery - #1585
Open
developerkunal wants to merge 6 commits into
Open
feat: add commands to list the command tree for easier discovery#1585developerkunal wants to merge 6 commits into
commands to list the command tree for easier discovery#1585developerkunal wants to merge 6 commits into
Conversation
Add a top-level `auth0 commands` that prints the full command tree with short descriptions, so the whole CLI surface can be discovered without inspecting each --help page individually. Supports three output shapes: - default nested tree with descriptions - --flat for one runnable command per line, ideal for scanning or intent matching - --json (with optional --detailed) exposing usage, arguments, flags, aliases and whether authentication is required Accepts an optional command path (e.g. `auth0 commands apps`) to scope the output to a single branch, and a --depth flag to limit nesting.
Contributor
|
Thanks for raising the PR! Before we route agents to the subcommands, we should ensure that they provide the same functionality as |
Combining --help with --json (or setting AUTH0_AGENT_MODE) now prints any command's help as JSON. This runs before Cobra parses flags, so it also works for the root and namespace commands that have no --json flag of their own. The usage footer points to `auth0 commands` and JSON help, and the homepage docs describe command discovery and agent mode.
--detailed previously only affected --json; the tree and flat text outputs ignored it. It now prints usage, args, aliases, auth and flags for each runnable command in every output shape, with multi-line flag help collapsed to a single line so the tree stays intact.
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.
🔧 Changes
Makes the CLI easy to discover and drive programmatically, both for people and AI agents.
auth0 commands— a new top-level command that prints the entire CLI command tree with a short description of each command, so the whole surface is discoverable in one place instead of inspecting each--helppage. Output shapes:--flatevery runnable command on its own line, easiest to scan or match an intent against.--jsonmachine-readable; with--detailedit also includes the usage line, positional arguments, local flags (name, shorthand, usage, type, default), aliases, and whether authentication is required, enough to construct a valid invocation programmatically.auth0 commands apps create) to scope to one branch, and--depthto limit levels. Requires no authentication.JSON help for any command — combining
--helpwith--jsonprints that command's help as JSON (the same detailed shape as above, plus anotethat steers an agent toauth0 apiwhen a needed field is not exposed as a flag). This is intercepted before Cobra parses flags, so it works for every command, including the root and namespace commands that have no--jsonflag of their own.Agent mode — setting
AUTH0_AGENT_MODE=1(any truthy value) makes--helpemit JSON without needing--json, which is convenient for scripts and AI agents.Discoverability touches — the usage footer now points to
auth0 commandsand JSON help, and the homepage docs gain a "Discovering and Scripting Commands" section.No new dependencies, and the tree-walking runs only when these paths are invoked, so there is no impact on the startup or runtime of other commands.
Demo
📚 References
N/A
🔬 Testing
internal/cli/commands_test.gocover tree building, depth limiting, detailed output, flat output (including the scoped case), positional-argument extraction that ignores flag values, help/JSON request detection, agent-mode env parsing, the fallback-note annotation, and the JSON-help interception (explicit--help --json, agent mode without--json, and the compact root overview).internal/clisuite passes andgo vetis clean.docs/auth0_commands.mdanddocs/index.mdstay in sync.Manual checks:
📝 Checklist