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

Commit

Permalink
Fix 1233: Removed printing of headers in snapctl
Browse files Browse the repository at this point in the history
Removes the printing of headers in snapctl when querying lists of
{tasks, plugins, metrics}. Instead provides `No x found` message and a
hint if appropriate.
  • Loading branch information
IRCody committed Oct 11, 2016
1 parent 87ab47c commit ffdd8d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/snapctl/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ func listMetrics(ctx *cli.Context) error {
if mts.Err != nil {
return fmt.Errorf("Error getting metrics: %v\n", mts.Err)
}

if mts.Len() == 0 {
fmt.Println("No metrics found. Have you loaded any collectors yet?")
return nil
}
/*
NAMESPACE VERSION
/intel/mock/foo 1,2
Expand Down
8 changes: 8 additions & 0 deletions cmd/snapctl/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,19 @@ func listPlugins(ctx *cli.Context) error {
}
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
if ctx.Bool("running") {
if len(plugins.AvailablePlugins) == 0 {
fmt.Println("No running plugins found. Have you started a task?")
return nil
}
printFields(w, false, 0, "NAME", "HIT COUNT", "LAST HIT", "TYPE")
for _, rp := range plugins.AvailablePlugins {
printFields(w, false, 0, rp.Name, rp.HitCount, time.Unix(rp.LastHitTimestamp, 0).Format(timeFormat), rp.Type)
}
} else {
if len(plugins.LoadedPlugins) == 0 {
fmt.Println("No plugins found. Have you loaded a plugin?")
return nil
}
printFields(w, false, 0, "NAME", "VERSION", "TYPE", "SIGNED", "STATUS", "LOADED TIME")
for _, lp := range plugins.LoadedPlugins {
printFields(w, false, 0, lp.Name, lp.Version, lp.Type, lp.Signed, lp.Status, lp.LoadedTime().Format(timeFormat))
Expand Down
4 changes: 4 additions & 0 deletions cmd/snapctl/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ func listTask(ctx *cli.Context) error {
}

w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
if tasks.Len() == 0 {
fmt.Println("No task found. Have you created a task?")
return nil
}
printFields(w, false, 0,
"ID",
"NAME",
Expand Down

0 comments on commit ffdd8d9

Please sign in to comment.