Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit b09893a

Browse files
authored
Merge pull request #303 from cben/cli-help
--help: List available analyzers, improve Usage line
2 parents a62c516 + 60b50ed commit b09893a

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

cmd/analyze.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ import (
2929
)
3030

3131
var analyzeCmd = &cobra.Command{
32-
Use: "analyze",
33-
Short: "Analyzes an image: [image]",
34-
Long: `Analyzes an image using the specifed analyzers as indicated via flags (see documentation for available ones).`,
32+
Use: "analyze image",
33+
Short: "Analyzes an image: container-diff image",
34+
Long: `Analyzes an image using the specifed analyzers as indicated via --type flag(s).
35+
36+
For details on how to specify images, run: container-diff help`,
3537
Args: func(cmd *cobra.Command, args []string) error {
3638
if err := validateArgs(args, checkAnalyzeArgNum, checkIfValidAnalyzer); err != nil {
3739
return err

cmd/diff.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ import (
3434
var filename string
3535

3636
var diffCmd = &cobra.Command{
37-
Use: "diff",
38-
Short: "Compare two images: [image1] [image2]",
39-
Long: `Compares two images using the specifed analyzers as indicated via flags (see documentation for available ones).`,
37+
Use: "diff image1 image2",
38+
Short: "Compare two images: container-diff image1 image2",
39+
Long: `Compares two images using the specifed analyzers as indicated via --type flag(s).
40+
41+
For details on how to specify images, run: container-diff help`,
4042
Args: func(cmd *cobra.Command, args []string) error {
4143
if err := validateArgs(args, checkDiffArgNum, checkIfValidAnalyzer, checkFilenameFlag); err != nil {
4244
return err

cmd/root.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,19 @@ func (d *diffTypes) Type() string {
223223
}
224224

225225
func addSharedFlags(cmd *cobra.Command) {
226+
sortedTypes := []string{}
227+
for analyzerType := range differs.Analyzers {
228+
sortedTypes = append(sortedTypes, analyzerType)
229+
}
230+
sort.Strings(sortedTypes)
231+
supportedTypes := strings.Join(sortedTypes, ", ")
232+
226233
cmd.Flags().BoolVarP(&json, "json", "j", false, "JSON Output defines if the diff should be returned in a human readable format (false) or a JSON (true).")
227-
cmd.Flags().VarP(&types, "type", "t", "This flag sets the list of analyzer types to use. Set it repeatedly to use multiple analyzers.")
234+
cmd.Flags().VarP(&types, "type", "t",
235+
fmt.Sprintf("This flag sets the list of analyzer types to use.\n"+
236+
"Set it repeatedly to use multiple analyzers.\n"+
237+
"Supported types: %s.",
238+
supportedTypes))
228239
cmd.Flags().BoolVarP(&save, "save", "s", false, "Set this flag to save rather than remove the final image filesystems on exit.")
229240
cmd.Flags().BoolVarP(&util.SortSize, "order", "o", false, "Set this flag to sort any file/package results by descending size. Otherwise, they will be sorted by name.")
230241
cmd.Flags().BoolVarP(&noCache, "no-cache", "n", false, "Set this to force retrieval of image filesystem on each run.")

0 commit comments

Comments
 (0)