mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-21 15:11:47 +00:00
Merge pull request #1590 from alex-petrov-vt/iss1585
Add no-header flag for get commands to omit printing the header
This commit is contained in:
commit
b01e27f50f
1 changed files with 6 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ var getCmd = &cobra.Command{
|
||||||
|
|
||||||
type GetFlags struct {
|
type GetFlags struct {
|
||||||
allNamespaces bool
|
allNamespaces bool
|
||||||
|
noHeader bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var getArgs GetFlags
|
var getArgs GetFlags
|
||||||
|
|
@ -47,6 +48,7 @@ var getArgs GetFlags
|
||||||
func init() {
|
func init() {
|
||||||
getCmd.PersistentFlags().BoolVarP(&getArgs.allNamespaces, "all-namespaces", "A", false,
|
getCmd.PersistentFlags().BoolVarP(&getArgs.allNamespaces, "all-namespaces", "A", false,
|
||||||
"list the requested object(s) across all namespaces")
|
"list the requested object(s) across all namespaces")
|
||||||
|
getCmd.PersistentFlags().BoolVarP(&getArgs.noHeader, "no-header", "", false, "skip the header when printing the results")
|
||||||
rootCmd.AddCommand(getCmd)
|
rootCmd.AddCommand(getCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,7 +119,10 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
header := get.list.headers(getArgs.allNamespaces)
|
var header []string
|
||||||
|
if !getArgs.noHeader {
|
||||||
|
header = get.list.headers(getArgs.allNamespaces)
|
||||||
|
}
|
||||||
var rows [][]string
|
var rows [][]string
|
||||||
for i := 0; i < get.list.len(); i++ {
|
for i := 0; i < get.list.len(); i++ {
|
||||||
row := get.list.summariseItem(i, getArgs.allNamespaces, getAll)
|
row := get.list.summariseItem(i, getArgs.allNamespaces, getAll)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue