Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
ref: normalize naming and layouts of lists (#417)
Browse files Browse the repository at this point in the history
This fixes 'duffle bundle list' to follow the same layout conventions as the other listing commands, and also standardizes the aliases across commands.
  • Loading branch information
technosophos authored Nov 15, 2018
1 parent 7703619 commit 4311a67
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
7 changes: 4 additions & 3 deletions cmd/duffle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Manages bundles

func newBundleCmd(w io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "bundle",
Short: "manage bundles",
Long: bundleDesc,
Use: "bundle",
Aliases: []string{"bundles"},
Short: "manage bundles",
Long: bundleDesc,
}
cmd.AddCommand(
newBundleListCmd(w),
Expand Down
23 changes: 17 additions & 6 deletions cmd/duffle/bundle_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,36 @@ func (n *NamedRepository) Digest() string {
}

func newBundleListCmd(w io.Writer) *cobra.Command {
var long bool
cmd := &cobra.Command{
Use: "list",
Short: "lists bundles pulled or built and stored locally",
Use: "list",
Aliases: []string{"ls"},
Short: "lists bundles pulled or built and stored locally",
RunE: func(cmd *cobra.Command, args []string) error {
home := home.Home(homePath())
references, err := searchLocal(home)
if err != nil {
return err
}
sort.Sort(references)
table := uitable.New()
table.AddRow("NAME", "VERSION", "DIGEST")
if long {
table := uitable.New()
table.AddRow("NAME", "VERSION", "DIGEST")
for _, ref := range references {
table.AddRow(ref.Name(), ref.Tag(), ref.Digest())
}
fmt.Fprintln(w, table)
return nil
}

for _, ref := range references {
table.AddRow(ref.Name(), ref.Tag(), ref.Digest())
fmt.Println(ref.Name())
}
fmt.Fprintln(w, table)

return nil
},
}
cmd.Flags().BoolVarP(&long, "long", "l", false, "output longer listing format")

return cmd
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/duffle/claims_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ func newClaimListCmd(out io.Writer) *cobra.Command {
list := listCmd{out: out}

cmd := &cobra.Command{
Use: "list",
Short: "list available claims",
Use: "list",
Aliases: []string{"ls"},
Short: "list available claims",
RunE: func(cmd *cobra.Command, args []string) error {
l := &listCmd{out: out, long: list.long}
return l.run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/duffle/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newCredentialsCmd(w io.Writer) *cobra.Command {
Use: "credentials",
Short: "manage credential sets",
Long: credentialDesc,
Aliases: []string{"creds", "credential"},
Aliases: []string{"creds", "credential", "cred"},
}

cmd.AddCommand(
Expand Down
2 changes: 1 addition & 1 deletion cmd/duffle/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Manages OpenPGP keys, signatures, and attestations.
func newKeyCmd(w io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "key",
Aliases: []string{"signature", "sig"},
Aliases: []string{"keys"},
Short: "manage keys",
Long: keyDesc,
}
Expand Down

0 comments on commit 4311a67

Please sign in to comment.