MCPcopy
hub / github.com/smallstep/cli / FirstStringOf

Function FirstStringOf

flags/flags.go:710–730  ·  view source on GitHub ↗

FirstStringOf returns the value of the first defined flag from the input list. If no defined flags, returns first flag with non-empty default value.

(ctx *cli.Context, flags ...string)

Source from the content-addressed store, hash-verified

708// FirstStringOf returns the value of the first defined flag from the input list.
709// If no defined flags, returns first flag with non-empty default value.
710func FirstStringOf(ctx *cli.Context, flags ...string) (string, string) {
711 // Return first defined flag.
712 for _, f := range flags {
713 if ctx.IsSet(f) {
714 return ctx.String(f), f
715 }
716 }
717 // Return first non-empty, default, flag value.
718 for _, f := range flags {
719 if val := ctx.String(f); val != "" {
720 return val, f
721 }
722 }
723
724 var name = "<unknown>"
725 if len(flags) > 0 {
726 name = flags[0]
727 }
728
729 return "", name
730}

Callers 3

OfflineTokenFlowFunction · 0.92
provisionerPromptFunction · 0.92
TestFirstStringOfFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by 1

TestFirstStringOfFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…