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

Commit

Permalink
Merge pull request #6 from postfinance/print_current_namespace_last
Browse files Browse the repository at this point in the history
print current namespace last, to improve readabilty of long lists
  • Loading branch information
ghouscht committed Feb 13, 2019
2 parents 13d71f7 + 2994f0a commit 24de75f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/ns.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type NsOptions struct {
// NewNsOptions provides an instance of NsOptions with default values
func NewNsOptions(streams genericclioptions.IOStreams) *NsOptions {
return &NsOptions{
configFlags: genericclioptions.NewConfigFlags(),
configFlags: genericclioptions.NewConfigFlags(true),
IOStreams: streams,
}
}
Expand Down Expand Up @@ -170,14 +170,19 @@ func (o *NsOptions) printNamespaces(namespaces []string) error {
}
currentNS := o.rawConfig.Contexts[o.rawConfig.CurrentContext].Namespace

current := false
for _, ns := range namespaces {
if ns == currentNS {
red.Fprintf(o.Out, "%s\n", ns)
current = true // postpone printing the current namespace
} else {
fmt.Fprintf(o.Out, "%s\n", ns)
}
}

if current {
red.Fprintf(o.Out, "%s\n", currentNS)
}

return nil
}

Expand Down

0 comments on commit 24de75f

Please sign in to comment.