// Usage will return the Usage object of the Command that matches the name
// provided as "command". Usage will return an error in the case that the
// command cannot be found by the given name.
436701
func (cs CommandSet) Usage(command string) (Usage, error) {
	cmd, ok := cs[command]
	if !ok {
		return Usage{}, fmt.Errorf("unknown command: %s", command)
	}

	return cmd.Usage(), nil
}
1176650
func (_m *CommandRegistrar) Command(name string, help string, onCommand common.CLICommand) *kingpin.CmdClause {
	ret := _m.Called(name, help, onCommand)

	var r0 *kingpin.CmdClause
	if rf, ok := ret.Get(0).(func(string, string, common.CLICommand) *kingpin.CmdClause); ok {
		r0 = rf(name, help, onCommand)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*kingpin.CmdClause)
		}
	}

	return r0
}
1219414
func FindCommand(a Application, name string) *Command {
	for _, c := range a.GetCommands() {
		if c.Name() == name {
			return c
		}
	}
	return nil
}
52771
func (g *Group) Use(middleware ...MiddlewareFunc) {
	g.middleware = append(g.middleware, middleware...)
	if len(g.middleware) == 0 {
		return
	}
	// Allow all requests to reach the group as they might get dropped if router
	// doesn't find a match, making none of the group middleware process.
	g.Any("", NotFoundHandler)
	g.Any("/*", NotFoundHandler)
}
644835
func commandUsage(method string) {
	usage, err := btcjson.MethodUsageText(method)
	if err != nil {
		// This should never happen since the method was already checked
		// before calling this function, but be safe.
		fmt.Fprintln(os.Stderr, "Failed to obtain command usage:", err)
		return
	}

	fmt.Fprintln(os.Stderr, "Usage:")
	fmt.Fprintf(os.Stderr, "  %s\n", usage)
}
545603
func Usage(format string, a ...interface{}) {
	console.ErrStyle("usage", format, a...)
	os.Exit(BadUsage)
}
1325271
func Get(ctx *cli.Context) command.Command {
	usage := "get service [name]"
	desc := "Returns a registered service"

	return command.NewCommand("get", usage, desc, func(args ...string) ([]byte, error) {
		if len(args) < 2 {
			return []byte("get what?"), nil
		}
		switch args[1] {
		case "service":
			if len(args) < 3 {
				return []byte("require service name"), nil
			}
			rsp, err := clic.GetService(ctx, args[2:])
			if err != nil {
				return nil, err
			}
			return rsp, nil
		default:
			return []byte("unknown command...\nsupported commands: \nget service [name]"), nil
		}
	})
}
1309302
func Call(ctx *cli.Context) command.Command {
	usage := "call [service] [endpoint] [request]"
	desc := "Returns the response for a service call"

	return command.NewCommand("call", usage, desc, func(args ...string) ([]byte, error) {
		var cargs []string

		for _, arg := range args {
			if len(strings.TrimSpace(arg)) == 0 {
				continue
			}
			cargs = append(cargs, arg)
		}

		if len(cargs) < 2 {
			return []byte("call what?"), nil
		}

		rsp, err := clic.CallService(ctx, cargs[1:])
		if err != nil {
			return nil, err
		}
		return rsp, nil
	})
}
367780
func (o *option) usageName() string {
	// Don't print help messages if we have none and there is only one
	// way to specify the option.
	if o.help == "" && (o.short == 0 || o.long == "") {
		return ""
	}
	n := ""

	switch {
	case o.short != 0 && o.long == "":
		n = "-" + string(o.short)
	case o.short == 0 && o.long != "":
		n = "    --" + o.long
	case o.short != 0 && o.long != "":
		n = "-" + string(o.short) + ", --" + o.long
	}

	switch {
	case o.flag:
		return n
	case o.optional:
		return n + "[=" + o.name + "]"
	case o.long != "":
		return n + "=" + o.name
	}
	return n + " " + o.name
}
1019008
func (p *Prometheus) Use(e *gin.Engine) {
	e.Use(p.HandlerFunc())
	p.SetMetricsPath(e)
}
1171243
func find(name string) *cobra.Command {
	for _, cmd := range root.Command.Commands() {
		if cmd.Name() == name {
			return cmd
		}
	}
	return nil
}
777366
func findCommand(search string, args []string, commands []*Command) (cmd *Command, name string) {
	if len(args) < 1 {
		return
	}
	if search == "" {
		search = args[0]
	} else {
		search = fmt.Sprintf("%s %s", search, args[0])
	}
	name = search
	for _, c := range commands {
		if c.Name == search {
			cmd = c
			// Clear the usage on flags as we will be printing our own
			// usage after parsing arguments
			c.Flags.Usage = func() {}
			if errHelp := c.Flags.Parse(args[1:]); errHelp != nil {
				printCommandUsage(cmd)
				os.Exit(ERROR_USAGE)
			}
			if len(cmd.Subcommands) != 0 {
				subArgs := cmd.Flags.Args()
				var subCmd *Command
				subCmd, name = findCommand(search, subArgs, cmd.Subcommands)
				if subCmd != nil {
					cmd = subCmd
				}
			}
			break
		}
	}
	return
}
872873
func Command(name string, arg ...string) *Cmd {
	return &Cmd{
		cmd: exec.Command(name, arg...),
	}
}
994535
func Usagef(cmd *cobra.Command, msg string, args ...interface{}) {
	txt := fmt.Sprintf(msg, args...)
	fmt.Fprintf(os.Stderr, "Error: %s\n\n", txt)
	cmd.Help()
	os.Exit(1)
}
791677
func (s *Service) Usage() {
	fmt.Printf("Usage of %s\n", os.Args[0])
	if s.commands["help"] != nil {
		fmt.Printf("    %-16s %s\n", "help", s.commands["help"].ShortUsage)
	}
	if s.commands["start"] != nil {
		fmt.Printf("    %-16s %s\n", "start", s.commands["start"].ShortUsage)
	}
	for k, cmd := range s.commands {
		if k == "start" || k == "help" {
			continue
		}
		fmt.Printf("    %-16s %s\n", k, cmd.ShortUsage)
	}
}
520647
func (cmd *Command) Usage() {
	cmd.UsageLine = strings.TrimSpace(cmd.UsageLine)

	tw := tabwriter.NewWriter(os.Stderr, 0, 8, 2, '\t', 0)
	defer tw.Flush()

	t := template.Must(template.New("usage").Parse(cmd.helpTemplate))
	t.Execute(tw, cmd.helpTemplateData)
}
612214
func (a *Application) Usage(args []string) {
	context, err := a.parseContext(true, args)
	a.FatalIfError(err, "")
	if err := a.UsageForContextWithTemplate(context, 2, a.usageTemplate); err != nil {
		panic(err)
	}
}