Skip to content

Commit

Permalink
Use --output/-o instead of --format
Browse files Browse the repository at this point in the history
Keep --format as a hidden flag for backward compat.
  • Loading branch information
cvaroqui committed Aug 23, 2023
1 parent 476da79 commit 6138fb9
Show file tree
Hide file tree
Showing 126 changed files with 178 additions and 175 deletions.
5 changes: 4 additions & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ func addFlagsGlobal(flagSet *pflag.FlagSet, p *commands.OptsGlobal) {
flagSet.BoolVar(&p.Local, "local", false, "Inline action on local instance.")
flagSet.BoolVarP(&p.Quiet, "quiet", "q", false, "Display no logs and no progress.")
flagSet.StringVar(&p.Color, "color", "auto", "Output colorization yes|no|auto.")
flagSet.StringVar(&p.Format, "format", "auto", "Output format json|flat|auto.")
flagSet.StringVar(&p.Output, "format", "auto", "Output format json|flat|auto|tab=<header>:<jsonpath>,...")
flagSet.StringVarP(&p.Output, "output", "o", "auto", "Output format json|flat|auto|tab=<header>:<jsonpath>,...")
flagSet.StringVar(&p.Log, "log", "", "Display the logs on the console at the specified level.")
flagSet.StringVar(&p.Server, "server", "", "URI of the opensvc api server. scheme raw|https.")
flagSet.StringVar(&p.NodeSelector, "node", "", "Execute on a list of nodes.")
flagSet.StringVarP(&p.ObjectSelector, "service", "s", "", "Execute on a list of objects.")
flagSet.MarkHidden("format")

}

func addFlagsLock(flagSet *pflag.FlagSet, p *commands.OptsLock) {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/array_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (t *CmdArrayLs) Run() error {
data, err = t.extractDaemon()
}
output.Renderer{
Format: t.Format,
Format: t.Output,
Color: t.Color,
Data: data,
HumanRenderer: func() string {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/cluster_freeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (t *CmdClusterFreeze) Run() error {
nodeaction.WithAsyncTime(t.Time),
nodeaction.WithAsyncWait(t.Wait),
nodeaction.WithAsyncWatch(t.Watch),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocal(false),
).Do()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/cluster_unfreeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (t *CmdClusterUnfreeze) Run() error {
nodeaction.WithAsyncTime(t.Time),
nodeaction.WithAsyncWait(t.Wait),
nodeaction.WithAsyncWatch(t.Watch),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocal(false),
).Do()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/daemon_dns_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (t *CmdDaemonDNSDump) Run() error {
return err
}
renderer := output.Renderer{
Format: t.Format,
Format: t.Output,
Color: t.Color,
Data: parsed,
Colorize: rawconfig.Colorize,
Expand Down
2 changes: 1 addition & 1 deletion core/commands/daemon_relay_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (t *CmdDaemonRelayStatus) Run() error {
})
}
output.Renderer{
Format: t.Format,
Format: t.Output,
Color: t.Color,
Data: messages,
Colorize: rawconfig.Colorize,
Expand Down
2 changes: 1 addition & 1 deletion core/commands/daemon_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type (
func (t *CmdDaemonStatus) Run() error {
m := monitor.New()
m.SetColor(t.Color)
m.SetFormat(t.Format)
m.SetFormat(t.Output)
m.SetSectionsFromExpression(t.Sections)

cli, err := newClient(t.Server)
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (t *CmdKeystoreAdd) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("add"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (t *CmdKeystoreChange) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("change"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *CmdKeystoreDecode) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("decode"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_gencert.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *CmdSecGenCert) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("gencert"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *CmdKeystoreInstall) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("install"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *CmdKeystoreKeys) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("keys"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_pkcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *CmdPKCS) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("pkcs"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/keystore_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (t *CmdKeystoreRemove) Run(selector, kind string) error {
objectaction.LocalFirst(),
objectaction.WithLocal(t.Local),
objectaction.WithColor(t.Color),
objectaction.WithFormat(t.Format),
objectaction.WithFormat(t.Output),
objectaction.WithObjectSelector(mergedSelector),
objectaction.WithRemoteNodes(t.NodeSelector),
objectaction.WithRemoteAction("keys"),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/network_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (t *CmdNetworkLs) Run() error {
data, err = t.extractDaemon()
}
output.Renderer{
Format: t.Format,
Format: t.Output,
Color: t.Color,
Data: data,
HumanRenderer: func() string {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/network_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (t *CmdNetworkStatus) Run() error {
return err
}
output.Renderer{
Format: t.Format,
Format: t.Output,
Color: t.Color,
Data: data,
Colorize: rawconfig.Colorize,
Expand Down
2 changes: 1 addition & 1 deletion core/commands/node_abort.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (t *CmdNodeAbort) Run() error {
nodeaction.WithRemoteAction("abort"),
nodeaction.WithAsyncTarget("aborted"),
nodeaction.WithAsyncWatch(t.Watch),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocal(t.Local),
).Do()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_capabilities_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ type (

func (t *CmdNodeCapabilitiesList) Run() error {
return nodeaction.New(
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),

nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithRemoteAction("node print capabilities"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
}),

nodeaction.WithLocal(t.Local),
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_capabilities_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ func (t *CmdNodeCapabilitiesScan) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("scan capabilities"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
}),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ func (t *CmdNodeChecks) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("checks"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
}),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/node_collector_tag_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type (
func (t *CmdNodeCollectorTagAttach) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/node_collector_tag_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type (
func (t *CmdNodeCollectorTagCreate) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/node_collector_tag_detach.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type (
func (t *CmdNodeCollectorTagDetach) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/node_collector_tag_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type (
func (t *CmdNodeCollectorTagList) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/node_collector_tag_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type (
func (t *CmdNodeCollectorTagShow) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_attach_moduleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ func (t *CmdNodeComplianceAttachModuleset) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance attach moduleset"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
}),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_attach_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ func (t *CmdNodeComplianceAttachRuleset) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance attach ruleset"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
}),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func (t *CmdNodeComplianceAuto) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance auto"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
"force": t.Force,
"module": t.Module,
"moduleset": t.Moduleset,
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func (t *CmdNodeComplianceCheck) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance check"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
"force": t.Force,
"module": t.Module,
"moduleset": t.Moduleset,
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_detach_moduleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ func (t *CmdNodeComplianceDetachModuleset) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance detach moduleset"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
"moduleset": t.Moduleset,
}),
nodeaction.WithLocalRun(func() (interface{}, error) {
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_detach_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ func (t *CmdNodeComplianceDetachRuleset) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance detach ruleset"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
}),
nodeaction.WithLocalRun(func() (interface{}, error) {
n, err := object.NewNode()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ func (t *CmdNodeComplianceEnv) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance env"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
"moduleset": t.Moduleset,
"module": t.Module,
}),
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func (t *CmdNodeComplianceFix) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance fix"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
"force": t.Force,
"module": t.Module,
"moduleset": t.Moduleset,
Expand Down
4 changes: 2 additions & 2 deletions core/commands/node_compliance_fixable.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func (t *CmdNodeComplianceFixable) Run() error {
return nodeaction.New(
nodeaction.WithLocal(t.Local),
nodeaction.WithRemoteNodes(t.NodeSelector),
nodeaction.WithFormat(t.Format),
nodeaction.WithFormat(t.Output),
nodeaction.WithColor(t.Color),
nodeaction.WithServer(t.Server),
nodeaction.WithRemoteAction("compliance fixable"),
nodeaction.WithRemoteOptions(map[string]interface{}{
"format": t.Format,
"format": t.Output,
"force": t.Force,
"module": t.Module,
"moduleset": t.Moduleset,
Expand Down
Loading

0 comments on commit 6138fb9

Please sign in to comment.