Skip to content

Commit

Permalink
Merge pull request #18 from feloy/fix-options
Browse files Browse the repository at this point in the history
Fix options
  • Loading branch information
feloy authored Nov 15, 2023
2 parents 6c32cb0 + 099a2d3 commit 3c27c43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ By default ports 1-1023 are privileged ports that only the root user can bind. W

An example of a wrong instruction that the tool would detect is
```
EXPOSE 8080
EXPOSE 80
```

with this printed message
Expand All @@ -92,7 +92,7 @@ To build and use the cli, execute

```
go build -o doa[.exe]
doa[.exe] analyze /your/local/project/path[/Dockerfile_name]
doa[.exe] analyze -f /your/local/project/path[/Dockerfile_name]
```

Contributing
Expand Down
18 changes: 9 additions & 9 deletions pkg/cli/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ func NewCmdAnalyze() *cobra.Command {
Run: doAnalyze,
Example: ` doa analyze -f /your/local/project/path[/Dockerfile_name]`,
}
analyzeCmd.PersistentFlags().String(
"f", "", "Container file to analyze",
analyzeCmd.PersistentFlags().StringP(
"file", "f", "", "Container file to analyze",
)
analyzeCmd.PersistentFlags().String(
"i", "", "Image name to analyze",
analyzeCmd.PersistentFlags().StringP(
"image", "i", "", "Image name to analyze",
)
analyzeCmd.PersistentFlags().String(
"o", "", "Specify output format, supported format: json",
analyzeCmd.PersistentFlags().StringP(
"output", "o", "", "Specify output format, supported format: json",
)
return analyzeCmd
}

func doAnalyze(cmd *cobra.Command, args []string) {
containerfile := cmd.Flag("f")
image := cmd.Flag("i")
containerfile := cmd.Flag("file")
image := cmd.Flag("image")
if containerfile.Value.String() == "" && image.Value.String() == "" {
PrintNoArgsWarningMessage(cmd.Name())
return
}

outputFunc := PrintPrettifyOutput
out := cmd.Flag("o")
out := cmd.Flag("output")
if out.Value.String() != "" && !strings.EqualFold(out.Value.String(), "json") {
RedirectErrorStringToStdErrAndExit(fmt.Sprintf("unknown value '%s' for flag %s, type --help for a list of all flags\n", out.Value.String(), out.Name))
} else if strings.EqualFold(out.Value.String(), "json") {
Expand Down

0 comments on commit 3c27c43

Please sign in to comment.