Skip to content

Commit

Permalink
Fix flags for agentctl
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
  • Loading branch information
ondrej-fabry committed Oct 15, 2019
1 parent fc5a019 commit db9690e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/agentctl/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (opts *ClientOptions) InstallFlags(flags *pflag.FlagSet) {
// complete
func (opts *ClientOptions) SetDefaultOptions(flags *pflag.FlagSet) {
client.DefaultPortHTTP = opts.PortHTTP
client.DefaultPortHTTP = opts.PortHTTP
client.DefaultPortGRPC = opts.PortGRPC
}

// SetLogLevel sets the logrus logging level
Expand Down
4 changes: 3 additions & 1 deletion cmd/agentctl/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ func NewRootNamed(name string, agentCli *cli.AgentCli) *Root {
func (root *Root) PrepareCommand() (*cobra.Command, error) {
cmd, args, err := root.HandleGlobalFlags()
if err != nil {
return nil, err
return nil, fmt.Errorf("handle global flags failed: %v", err)
}
if debug.IsEnabledFor("flags") {
fmt.Printf("flag.Args() = %v\n", args)
cmd.DebugFlags()
}
cmd.SetArgs(args)
Expand Down Expand Up @@ -114,6 +115,7 @@ func newRoot(cmd *cobra.Command, agentCli *cli.AgentCli, opts *cli.ClientOptions
func (root *Root) HandleGlobalFlags() (*cobra.Command, []string, error) {
cmd := root.cmd
flags := pflag.NewFlagSet(cmd.Name(), pflag.ContinueOnError)
flags.SetInterspersed(false)

// We need the single parse to see both sets of flags.
flags.AddFlagSet(cmd.Flags())
Expand Down

0 comments on commit db9690e

Please sign in to comment.