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

--help: List available analyzers, improve Usage line #303

Merged
merged 1 commit into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import (
)

var analyzeCmd = &cobra.Command{
Use: "analyze",
Short: "Analyzes an image: [image]",
Long: `Analyzes an image using the specifed analyzers as indicated via flags (see documentation for available ones).`,
Use: "analyze image",
Short: "Analyzes an image: container-diff image",
Long: `Analyzes an image using the specifed analyzers as indicated via --type flag(s).

For details on how to specify images, run: container-diff help`,
Args: func(cmd *cobra.Command, args []string) error {
if err := validateArgs(args, checkAnalyzeArgNum, checkIfValidAnalyzer); err != nil {
return err
Expand Down
8 changes: 5 additions & 3 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ import (
var filename string

var diffCmd = &cobra.Command{
Use: "diff",
Short: "Compare two images: [image1] [image2]",
Long: `Compares two images using the specifed analyzers as indicated via flags (see documentation for available ones).`,
Use: "diff image1 image2",
Short: "Compare two images: container-diff image1 image2",
Long: `Compares two images using the specifed analyzers as indicated via --type flag(s).

For details on how to specify images, run: container-diff help`,
Args: func(cmd *cobra.Command, args []string) error {
if err := validateArgs(args, checkDiffArgNum, checkIfValidAnalyzer, checkFilenameFlag); err != nil {
return err
Expand Down
13 changes: 12 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,19 @@ func (d *diffTypes) Type() string {
}

func addSharedFlags(cmd *cobra.Command) {
sortedTypes := []string{}
for analyzerType := range differs.Analyzers {
sortedTypes = append(sortedTypes, analyzerType)
}
sort.Strings(sortedTypes)
supportedTypes := strings.Join(sortedTypes, ", ")

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).")
cmd.Flags().VarP(&types, "type", "t", "This flag sets the list of analyzer types to use. Set it repeatedly to use multiple analyzers.")
cmd.Flags().VarP(&types, "type", "t",
fmt.Sprintf("This flag sets the list of analyzer types to use.\n"+
"Set it repeatedly to use multiple analyzers.\n"+
"Supported types: %s.",
supportedTypes))
cmd.Flags().BoolVarP(&save, "save", "s", false, "Set this flag to save rather than remove the final image filesystems on exit.")
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.")
cmd.Flags().BoolVarP(&noCache, "no-cache", "n", false, "Set this to force retrieval of image filesystem on each run.")
Expand Down