Update repo_list.go

Signed-off-by: pipi1111111 <154908679+pipi1111111@users.noreply.github.com>
pull/30608/head
pipi1111111 7 months ago committed by GitHub
parent bce6d0ec25
commit eddbf39253
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -37,11 +37,17 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
Args: require.NoArgs,
ValidArgsFunction: noMoreArgsCompFunc,
RunE: func(_ *cobra.Command, _ []string) error {
f, _ := repo.LoadFile(settings.RepositoryConfig)
if len(f.Repositories) == 0 {
switch outfmt {
case output.Table:
fmt.Fprintln(out, "no repositories to show")
return nil
case output.JSON, output.YAML:
return outfmt.Write(out, &repoListWriter{repos: []*repo.Entry{}})
}
return outfmt.Write(out, &repoListWriter{f.Repositories})
},
}
bindOutputFlag(cmd, &outfmt)
return cmd
@ -57,10 +63,6 @@ type repoListWriter struct {
}
func (r *repoListWriter) WriteTable(out io.Writer) error {
if len(r.repos) == 0 {
_, _ = fmt.Fprintln(out, "no repositories to show")
return nil
}
table := uitable.New()
table.AddRow("NAME", "URL")
for _, re := range r.repos {

Loading…
Cancel
Save