Add --json option support
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
This commit is contained in:
parent
9d8b783304
commit
96549077cc
1 changed files with 9 additions and 0 deletions
|
|
@ -64,6 +64,7 @@ func NewCmdGet(f *cmdutil.Factory, runF func(*GetOptions) error) *cobra.Command
|
|||
}
|
||||
cmd.Flags().StringVarP(&opts.OrgName, "org", "o", "", "Get a variable for an organization")
|
||||
cmd.Flags().StringVarP(&opts.EnvName, "env", "e", "", "Get a variable for an environment")
|
||||
cmdutil.AddJSONFlags(cmd, &opts.Exporter, shared.VariableJSONFields)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
@ -118,6 +119,14 @@ func getRun(opts *GetOptions) error {
|
|||
return fmt.Errorf("failed to get variable %s: %w", opts.VariableName, err)
|
||||
}
|
||||
|
||||
if err := shared.PopulateSelectedRepositoryInformation(client, host, &variable); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.Exporter != nil {
|
||||
return opts.Exporter.Write(opts.IO, &variable)
|
||||
}
|
||||
|
||||
fmt.Fprintf(opts.IO.Out, "%s\n", variable.Value)
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue