feat(flags): add --list/-l flag to display available commands and environments#36
Merged
seanseannery merged 1 commit intomainfrom Mar 7, 2026
Merged
Conversation
…ironments Adds a new --list/-l flag that prints Opsfile commands with descriptions and environments without executing anything. Also integrates command listing into --help output with silent fallback when no Opsfile is found. Closes #19
This was referenced Mar 7, 2026
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.
Key Changes
--list/-lCLI flag that prints a summary of all commands and environments defined in the Opsfile, then exits# commentdescriptions from the first line of a comment block directly above a command declaration--helpnow appends command listing after flag help (silently skips if no Opsfile found)internal/lister.gomodule handles formatted output with column-aligned descriptionsWhy do we need this?
There is no way to discover available commands without opening the Opsfile manually. Under time pressure (e.g. during incidents), this adds unnecessary friction. The
--listflag provides instant command discovery from the terminal.Closes #19
New modules or other dependencies introduced
internal/lister.go— new file containingFormatCommandList()for rendering the command/environment listing. Uses only the standard library (fmt,io,strings).internal/lister_test.go— 7 table-driven test cases for output formattingNo new external dependencies.
How was this tested?
--list/-lflag parsing including combination with-Dcommand_resolver_test.goupdated for newParseOpsFilereturn signatureops --list -D ./examplesproduces correct output against the example Opsfilemake lintandmake testpass (88 tests total)