Skip to content

Commit

Permalink
feat: allow specifying unknown marker in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
shivjm committed Nov 7, 2021
1 parent bea4d33 commit 13afe26
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions main.go
Expand Up @@ -11,16 +11,14 @@ import (
"github.com/spf13/cobra"
)

const (
UNKNOWN_MARKER = "?"
)

type Image struct {
Name string `json:"name"`
Tag string `json:"tag"`
}

func main() {
var unknownMarker string

var rootCmd = &cobra.Command{
Use: "dockerfile-image-tags",
Short: "List images & tags used in a Dockerfile.",
Expand All @@ -38,7 +36,7 @@ func main() {
log.Fatalf("Could not parse Dockerfile: %s\n", err)
}

images := getTags(parsed, UNKNOWN_MARKER)
images := getTags(parsed, unknownMarker)

val, err := json.Marshal(images)

Expand All @@ -49,6 +47,7 @@ func main() {
fmt.Println(string(val))
},
}
rootCmd.Flags().StringVarP(&unknownMarker, "unknown-marker", "m", "?", "string to use to indicate unknown tags")

if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 13afe26

Please sign in to comment.