Skip to content

feat: add commands to list the command tree for easier discovery - #1585

Open
developerkunal wants to merge 6 commits into
mainfrom
feat/commands-tree
Open

feat: add commands to list the command tree for easier discovery#1585
developerkunal wants to merge 6 commits into
mainfrom
feat/commands-tree

Conversation

@developerkunal

@developerkunal developerkunal commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

🔧 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 --help page. Output shapes:

  • Default nested tree, easy to scan visually.
  • --flat every runnable command on its own line, easiest to scan or match an intent against.
  • --json machine-readable; with --detailed it 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.
  • Accepts an optional command path (for example auth0 commands apps create) to scope to one branch, and --depth to limit levels. Requires no authentication.

JSON help for any command — combining --help with --json prints that command's help as JSON (the same detailed shape as above, plus a note that steers an agent to auth0 api when 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 --json flag of their own.

Agent mode — setting AUTH0_AGENT_MODE=1 (any truthy value) makes --help emit JSON without needing --json, which is convenient for scripts and AI agents.

Discoverability touches — the usage footer now points to auth0 commands and 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

pr-demo

📚 References

N/A

🔬 Testing

  • Unit tests in internal/cli/commands_test.go cover 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).
  • The full internal/cli suite passes and go vet is clean.
  • Regenerated the docs so docs/auth0_commands.md and docs/index.md stay in sync.

Manual checks:

auth0 commands
auth0 commands --flat
auth0 commands apps show --json --detailed
auth0 apps create --help --json
AUTH0_AGENT_MODE=1 auth0 apps create --help

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

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.
@developerkunal
developerkunal requested a review from a team as a code owner July 10, 2026 20:22
@ramya18101

Copy link
Copy Markdown
Contributor

Thanks for raising the PR!

Before we route agents to the subcommands, we should ensure that they provide the same functionality as auth0 api does today, specifically, the ability to accept the complete request schema as a payload.

developerkunal and others added 4 commits August 12, 2026 13:43
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants