-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem
Currently, when CLI commands (build, list, docgen) encounter errors, Cobra automatically prints both the usage message and the error message. This creates verbose and confusing output that makes it difficult for users to quickly identify the actual error.
Current Behavior
When a command fails (e.g., invalid configuration, missing files, build errors), the output looks like:
Usage:
dib build [flags]
Flags:
--backend string Build Backend used to run image builds...
--buildkit-host string buildkit host address.
-f, --file string Name of the Dockerfile
... (many more flags)
Error: build failed: cannot generate DAG: invalid configuration
Expected Behavior
Commands should only display the relevant error message without the usage text:
Error: build failed: cannot generate DAG: invalid configuration
Impact
- User Experience: Cluttered output makes it harder to spot actual errors
- CI/CD: Verbose error logs in automated pipelines
- Debugging: Important error messages get buried in usage text
Proposed Solution
Add SilenceErrors: true
and SilenceUsage: true
to Cobra command definitions to prevent automatic usage printing while preserving custom error handling.
Commands Affected
- dib build
- dib list
- dib docgen
Additional Context
The root command already has these settings configured correctly. This issue ensures consistency across all CLI commands.