Skip to content

Commit 9385a78

Browse files
authored
feat: add Long descriptions and Examples to all CLI commands (#494)
Add detailed Long descriptions and usage Examples to every Cobra command definition. This improves the built-in help output and provides the source material for auto-generated CLI reference documentation.
1 parent 50bcc35 commit 9385a78

29 files changed

+273
-13
lines changed

internal/app/azldev/app.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ func NewApp(fsFactory opctx.FileSystemFactory, osEnvFactory opctx.OSEnvFactory)
106106

107107
// Define the top-level command for the CLI.
108108
app.cmd = cobra.Command{
109-
Use: "azldev",
110-
Short: usageInfo,
111-
Long: usageInfo,
109+
Use: "azldev",
110+
Short: usageInfo,
111+
Long: `Azure Linux Dev Tool (azldev) manages Azure Linux projects, components,
112+
images, and builds. It provides a unified CLI for the full development
113+
workflow: creating projects, importing and building RPM packages,
114+
customizing images, and more.
115+
116+
Run azldev from the root of an Azure Linux project (where azldev.toml
117+
lives), or use -C to point to one.`,
112118
Version: displayVersion,
113119
PersistentPreRunE: func(command *cobra.Command, _ []string) error {
114120
slog.Debug("Command annotations", "annotations", command.Annotations)

internal/app/azldev/cmds/advanced/advanced.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ func OnAppInit(app *azldev.App) {
1414
Use: "advanced",
1515
Aliases: []string{"adv"},
1616
Short: "Advanced operations",
17-
Hidden: true,
17+
Long: `Advanced operations for power users and automation.
18+
19+
These commands provide low-level access to mock, MCP server mode,
20+
and direct file downloads. They are hidden from the default help
21+
output but fully supported.`,
22+
Hidden: true,
1823
}
1924

2025
app.AddTopLevelCommand(cmd)

internal/app/azldev/cmds/advanced/mcp.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ func NewMCPCmd() *cobra.Command {
2121
cmd := &cobra.Command{
2222
Use: "mcp",
2323
Short: "Run in MCP server mode",
24+
Long: `Start azldev as a Model Context Protocol (MCP) server.
25+
26+
In this mode, azldev communicates over stdin/stdout using the MCP protocol,
27+
exposing selected commands as tools that can be invoked by AI coding agents
28+
and other MCP clients.`,
29+
Example: ` # Start the MCP server
30+
azldev advanced mcp`,
2431
RunE: (func(cmd *cobra.Command, args []string) error {
2532
env, err := azldev.GetEnvFromCommand(cmd)
2633
if err != nil {

internal/app/azldev/cmds/advanced/mock.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func NewMockCmd() *cobra.Command {
2323
cmd := &cobra.Command{
2424
Use: "mock",
2525
Short: "Run RPM mock tool",
26+
Long: `Run RPM mock tool commands directly.
27+
28+
Provides low-level access to mock for building RPMs from SRPMs and
29+
starting interactive shell sessions in mock chroot environments.`,
2630
}
2731

2832
cmd.AddCommand(NewBuildRPMCmd())
@@ -58,6 +62,16 @@ func NewBuildRPMCmd() *cobra.Command {
5862
cmd := &cobra.Command{
5963
Use: "build-rpms",
6064
Short: "Use mock to build an RPM",
65+
Long: `Build binary RPMs from a source RPM using mock.
66+
67+
This is a low-level command that invokes mock directly with the given
68+
SRPM and configuration. For most use cases, prefer 'azldev component build'
69+
which handles source preparation and overlay application automatically.`,
70+
Example: ` # Build from an SRPM
71+
azldev advanced mock build-rpms --srpm ./my-package.src.rpm -o ./rpms/
72+
73+
# Build with a custom mock config
74+
azldev advanced mock build-rpms -c my-mock.cfg --srpm ./my-package.src.rpm -o ./rpms/`,
6175
RunE: azldev.RunFuncWithoutRequiredConfig(func(env *azldev.Env) (results interface{}, err error) {
6276
return BuildRPMS(env, options)
6377
}),
@@ -94,6 +108,22 @@ func NewShellCmd() *cobra.Command {
94108
cmd := &cobra.Command{
95109
Use: "shell",
96110
Short: "Enter mock shell",
111+
Long: `Start an interactive shell inside a mock chroot environment.
112+
113+
This is useful for inspecting built RPMs, debugging package issues, or
114+
running smoke tests. Packages can be pre-installed into the chroot using
115+
--add-package. Extra arguments after -- are passed to the shell command.`,
116+
Example: ` # Open a mock shell
117+
azldev advanced mock shell
118+
119+
# Open a shell with packages pre-installed
120+
azldev advanced mock shell --add-package /path/to/my-package.rpm
121+
122+
# Open a shell with network access
123+
azldev advanced mock shell --enable-network
124+
125+
# Run a command inside the mock shell
126+
azldev advanced mock shell -- rpm -qa`,
97127
RunE: azldev.RunFuncWithoutRequiredConfigWithExtraArgs(
98128
func(env *azldev.Env, extraArgs []string) (results interface{}, err error) {
99129
return true, RunShell(env, options, extraArgs)

internal/app/azldev/cmds/advanced/wget.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ func NewWgetCmd() *cobra.Command {
2929
cmd := &cobra.Command{
3030
Use: "wget URI",
3131
Short: "Download files via https",
32+
Long: `Download a file from an HTTPS URI to a local path.
33+
34+
This is a simple download utility that respects azldev's network retry
35+
configuration. It is primarily used internally but can be invoked directly.`,
36+
Example: ` # Download a file
37+
azldev advanced wget --uri https://example.com/file.tar.gz -o ./file.tar.gz`,
3238
RunE: azldev.RunFuncWithoutRequiredConfig(func(env *azldev.Env) (results interface{}, err error) {
3339
return true, Download(env, options)
3440
}),

internal/app/azldev/cmds/component/add.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ func NewComponentAddCommand() *cobra.Command {
3232
cmd := &cobra.Command{
3333
Use: "add",
3434
Short: "Add component(s) to this project",
35+
Long: `Add one or more components to the project configuration.
36+
37+
Each component name is added as a bare entry in the root config file,
38+
inheriting defaults from the distro configuration. If a component with
39+
the same name already exists, the command returns an error.`,
40+
Example: ` # Add a single component
41+
azldev component add curl
42+
43+
# Add multiple components at once
44+
azldev component add curl wget bash`,
3545
RunE: azldev.RunFuncWithExtraArgs(func(env *azldev.Env, args []string) (interface{}, error) {
3646
return true, AddComponentsToConfig(env.FS(), env.Config(), options, args)
3747
}),

internal/app/azldev/cmds/component/build.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ func NewBuildCmd() *cobra.Command {
6262
cmd := &cobra.Command{
6363
Use: "build",
6464
Short: "Build packages for components",
65+
Long: `Build RPM packages for one or more components using mock.
66+
67+
This command fetches upstream sources (applying any configured overlays),
68+
creates an SRPM, and invokes mock to produce binary RPMs. Built packages
69+
are placed in the project's output directory.
70+
71+
Use --local-repo-with-publish to build a chain of dependent components:
72+
each component's RPMs are published to a local repository that subsequent
73+
builds can consume.`,
74+
Example: ` # Build a single component
75+
azldev component build -p curl
76+
77+
# Build all components, continuing past failures
78+
azldev component build -a -k
79+
80+
# Build SRPM only (skip binary RPM build)
81+
azldev component build -p curl --srpm-only
82+
83+
# Chain-build dependent components with a local repo
84+
azldev component build --local-repo-with-publish ./base/out -p liba -p libb`,
6585
RunE: azldev.RunFuncWithExtraArgs(func(env *azldev.Env, args []string) (interface{}, error) {
6686
options.ComponentFilter.ComponentNamePatterns = append(options.ComponentFilter.ComponentNamePatterns, args...)
6787

internal/app/azldev/cmds/component/component.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ func OnAppInit(app *azldev.App) {
1414
Use: "component",
1515
Aliases: []string{"comp"},
1616
Short: "Manage components",
17+
Long: `Manage components in an Azure Linux project.
18+
19+
Components are the primary unit of packaging — each corresponds to exactly one
20+
RPM spec file. Building a component results in producing one or more RPM packages.
21+
Use subcommands to add, list, query, build, and prepare sources for
22+
components defined in the project configuration.`,
1723
}
1824

1925
app.AddTopLevelCommand(cmd)

internal/app/azldev/cmds/component/list.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ func NewComponentListCommand() *cobra.Command {
3030
cmd := &cobra.Command{
3131
Use: "list",
3232
Short: "List components in this project",
33+
Long: `List components defined in the project configuration.
34+
35+
By default only matching components are shown. Use -a to list all components.
36+
Component name patterns support glob syntax (*, ?, []).`,
37+
Example: ` # List all components
38+
azldev component list -a
39+
40+
# List a specific component
41+
azldev component list -p curl
42+
43+
# List components matching a pattern
44+
azldev component list -p "azure*"
45+
46+
# Output as JSON for scripting
47+
azldev component list -a -q -O json`,
3348
RunE: azldev.RunFuncWithExtraArgs(func(env *azldev.Env, args []string) (interface{}, error) {
3449
options.ComponentFilter.ComponentNamePatterns = append(args, options.ComponentFilter.ComponentNamePatterns...)
3550

internal/app/azldev/cmds/component/preparesources.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ func NewPrepareSourcesCmd() *cobra.Command {
3434
Use: "prepare-sources",
3535
Aliases: []string{"prep-sources"},
3636
Short: "Prepare buildable sources for components",
37+
Long: `Prepare buildable sources for a component by fetching the upstream spec and
38+
source files, then applying any configured overlays.
39+
40+
The result is a directory containing the spec file and all sources, ready
41+
for inspection or manual building. This is useful for verifying that
42+
overlays apply cleanly before running a full build.
43+
44+
Only one component may be selected at a time.`,
45+
Example: ` # Prepare sources for a component
46+
azldev component prep-sources -p curl -o ./build/work/scratch/curl --force
47+
48+
# Prepare without applying overlays (raw upstream sources)
49+
azldev component prep-sources -p curl -o ./build/work/scratch/curl --skip-overlays --force`,
3750
RunE: azldev.RunFuncWithExtraArgs(func(env *azldev.Env, args []string) (interface{}, error) {
3851
options.ComponentFilter.ComponentNamePatterns = append(args, options.ComponentFilter.ComponentNamePatterns...)
3952

0 commit comments

Comments
 (0)