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

Commit

Permalink
add no-prefix for cap cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Apr 16, 2020
1 parent 194b5be commit dcfcee5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cmd/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,21 @@ var capabilitiesCmd = &cobra.Command{
log.Printf("error sending capabilities request: %v", err)
return
}

fmt.Printf("[%s] gNMI_Version: %s\n", address, response.GNMIVersion)
printPrefix := ""
if len(addresses) > 1 && !viper.GetBool("no-prefix") {
printPrefix = fmt.Sprintf("[%s] ", address)
}
fmt.Printf("%sgNMI_Version: %s\n", printPrefix, response.GNMIVersion)
if viper.GetBool("version") {
return
}
fmt.Printf("[%s] supported models:\n", address)
fmt.Printf("%ssupported models:\n", printPrefix)
for _, sm := range response.SupportedModels {
fmt.Printf("[%s] - %s, %s, %s\n", address, sm.GetName(), sm.GetOrganization(), sm.GetVersion())
fmt.Printf("%s - %s, %s, %s\n", printPrefix, sm.GetName(), sm.GetOrganization(), sm.GetVersion())
}
fmt.Printf("[%s] supported encodings:\n", address)
fmt.Printf("%ssupported encodings:\n", printPrefix)
for _, se := range response.SupportedEncodings {
fmt.Printf("[%s] - %s\n", address, se.String())
fmt.Printf("%s - %s\n", printPrefix, se.String())
}
fmt.Println()
}(addr)
Expand Down

0 comments on commit dcfcee5

Please sign in to comment.