{"modulePath":"github.com/context-dot-dev/context-dev-cli","version":"v1.28.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package requestflag\n\n## Functions\n\n```go\nfunc ApplyStdinDataToFlags(cmd *cli.Command, data map[string]any) error\n```\nApplyStdinDataToFlags sets flag values from a parsed stdin data map for flags that have not already been set via the command line. This allows piped YAML/JSON data to satisfy path, query, and header parameters. Body parameters are excluded: they are already handled by the maps.Copy merge in flagOptions. For each unset flag, if the parsed data map contains a key matching the flag's QueryPath, HeaderPath, or PathParam (or any of its DataAliases), the flag is set to that value via flag.Set.\n\nInner flags (those with an outer flag) are also handled: if the outer flag's body path key exists in the data map and contains a nested map with a key matching the inner flag's field (or aliases), the inner flag is set from that nested value.\n\n```go\nfunc CheckInnerFlags(cmd cli.Command) error\n```\nHelper function to verify that all inner flags have an outer flag set and follow the --foo.baz prefix format\n\n```go\nfunc GetMissingRequiredFlags(cmd *cli.Command, body any) []cli.Flag\n```\n\n```go\nfunc Ptr[T any](v T) *T\n```\nPtr returns a pointer to its argument. It is used to initialize \\`Default\\` on pointer-typed Flag values, since Go does not allow taking the address of a composite literal's element or of an untyped constant.\n\n```go\nfunc WithInnerFlags(cmd cli.Command, innerFlagMap map[string][]HasOuterFlag) cli.Command\n```\nWithInnerFlags takes a command and a map of flag names to inner flags, and returns a modified command with the appropriate inner flags set.\n\n## Types\n\n```go\ntype DateTimeValue string\n```\n\n```go\nfunc (d *DateTimeValue) Parse(s string) error\n```\n\n```go\nfunc (d DateTimeValue) String() string\n```\n\n```go\ntype DateValue string\n```\nTime-related value types\n\n```go\nfunc (d *DateValue) Parse(s string) error\n```\nParse methods for time-related types\n\n```go\nfunc (d DateValue) String() string\n```\nString methods for time-related types\n\n```go\ntype Flag[\n\tT []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string |\n\t\t[]float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue |\n\t\tstring | float64 | int64 | bool |\n\t\t*string | *float64 | *int64 | *bool | *DateTimeValue | *DateValue | *TimeValue,\n] struct {\n\tName        string               // name of the flag\n\tCategory    string               // category of the flag, if any\n\tDefaultText string               // default text of the flag for usage purposes\n\tHideDefault bool                 // whether to hide the default value in output\n\tUsage       string               // usage string for help output\n\tSources     cli.ValueSourceChain // sources to load flag value from\n\tRequired    bool                 // whether the flag is required or not\n\tHidden      bool                 // whether to hide the flag in help output\n\tDefault     T                    // default value for this flag if not set by from any source\n\tAliases     []string             // aliases that are allowed for this flag\n\tValidator   func(T) error        // custom function to validate this flag value\n\n\tQueryPath  string // location in the request query string to put this flag's value\n\tHeaderPath string // location in the request header to put this flag's value\n\tBodyPath   string // location in the request body to put this flag's value\n\tBodyRoot   bool   // if true, then use this value as the entire request body\n\tPathParam  string // name of the URL path parameter this flag's value maps to\n\n\t// Const, when true, marks this flag as a constant. The flag's Default value is used as the fixed value\n\t// and always included in the request (IsSet returns true). The user can still see and override the flag,\n\t// but isn't required to provide it. This is used for single-value enums and `x-stainless-const`\n\t// parameters.\n\tConst bool\n\n\t// FileInput, when true, indicates that the flag value is always treated as a file path. The file is read\n\t// automatically without requiring the \"@\" prefix. This is used for parameters with `type: string, format:\n\t// binary` in the OpenAPI spec.\n\tFileInput bool\n\n\t// DataAliases is a list of alternate names for this parameter recognized when parsing piped YAML/JSON\n\t// input. Values keyed by any alias are translated to the canonical API name before being sent.\n\tDataAliases []string\n\t// contains filtered or unexported fields\n}\n```\nFlag \\[T] is a generic flag base which can be used to implement the most common interfaces used by urfave/cli. Additionally, it allows specifying where in an HTTP request the flag values should be placed (e.g. query, body, etc.).\n\nPointer-to-primitive type parameters (e.g. \\*string) are used for flags whose underlying schema is nullable. They give flags a tri-state: unset (excluded from the request), set to the literal \"null\" (nil pointer → JSON null), or set to a value (\\*v → JSON value).\n\n```go\nfunc (f *Flag[T]) Count() int\n```\n\n```go\nfunc (f *Flag[T]) Get() any\n```\n\n```go\nfunc (f Flag[T]) GetBodyPath() string\n```\n\n```go\nfunc (f *Flag[T]) GetCategory() string\n```\n\n```go\nfunc (f Flag[T]) GetDataAliases() []string\n```\n\n```go\nfunc (f *Flag[T]) GetDefaultText() string\n```\n\n```go\nfunc (f *Flag[T]) GetEnvVars() []string\n```\nGetEnvVars returns the env vars for this flag\n\n```go\nfunc (f Flag[T]) GetHeaderPath() string\n```\n\n```go\nfunc (f Flag[T]) GetPathParam() string\n```\n\n```go\nfunc (f Flag[T]) GetQueryPath() string\n```\n\n```go\nfunc (f *Flag[T]) GetUsage() string\n```\n\n```go\nfunc (f *Flag[T]) GetValue() string\n```\n\n```go\nfunc (f Flag[T]) IsBodyRoot() bool\n```\n\n```go\nfunc (f *Flag[T]) IsBoolFlag() bool\n```\n\n```go\nfunc (f *Flag[T]) IsDefaultVisible() bool\n```\n\n```go\nfunc (f Flag[T]) IsFileInput() bool\n```\n\n```go\nfunc (f Flag[T]) IsLocal() bool\n```\n\n```go\nfunc (f *Flag[T]) IsMultiValueFlag() bool\n```\n\n```go\nfunc (f *Flag[T]) IsRequired() bool\n```\n\n```go\nfunc (f *Flag[T]) IsRequiredAsFlagOrStdin() bool\n```\n\n```go\nfunc (f *Flag[T]) IsSet() bool\n```\n\n```go\nfunc (f *Flag[T]) IsVisible() bool\n```\n\n```go\nfunc (f *Flag[T]) Names() []string\n```\n\n```go\nfunc (f *Flag[T]) PostParse() error\n```\n\n```go\nfunc (f *Flag[T]) PreParse() error\n```\n\n```go\nfunc (f *Flag[T]) SeedInnerCollection(isArrayOfObjects bool)\n```\nSeedInnerCollection initializes a Flag\\[any]'s underlying value as an empty map\\[string]any or \\[]map\\[string]any so subsequent SetInnerField calls have a dispatchable reflect.Kind. For typed Flag\\[T] this is a no-op: the type assertion fails and the existing reflect.Kind on the typed-nil zero value already routes correctly.\n\n```go\nfunc (f *Flag[T]) Set(name string, val string) error\n```\n\n```go\nfunc (f *Flag[T]) SetCategory(c string)\n```\n\n```go\nfunc (f *Flag[T]) SetInnerField(field string, val any)\n```\n\n```go\nfunc (f *Flag[T]) String() string\n```\n\n```go\nfunc (f *Flag[T]) TakesValue() bool\n```\n\n```go\nfunc (f *Flag[T]) TypeName() string\n```\n\n```go\ntype HasOuterFlag interface {\n\tcli.Flag\n\tSetOuterFlag(cli.Flag)\n\tGetOuterFlag() cli.Flag\n\tGetInnerField() string\n\tGetDataAliases() []string\n}\n```\n\n```go\ntype InRequest interface {\n\tGetQueryPath() string\n\tGetHeaderPath() string\n\tGetBodyPath() string\n\tGetPathParam() string\n\tIsBodyRoot() bool\n\tIsFileInput() bool\n\tGetDataAliases() []string\n}\n```\nInRequest interface for flags that should be included in HTTP requests\n\n```go\ntype InnerFieldSeeder interface {\n\tSeedInnerCollection(isArrayOfObjects bool)\n}\n```\nInnerFieldSeeder lets an InnerFlag prepare its outer flag's underlying value before dispatching SetInnerField. This is only meaningful for Flag\\[any] — the codegen output for nullable complex schemas — whose untyped-nil zero value would otherwise have no reflect.Kind for the inner-field switch to dispatch on.\n\n```go\ntype InnerFlag[\n\tT []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string |\n\t\t[]float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue |\n\t\tstring | float64 | int64 | bool |\n\t\t*string | *float64 | *int64 | *bool | *DateTimeValue | *DateValue | *TimeValue,\n] struct {\n\tName        string        // name of the flag\n\tDefaultText string        // default text of the flag for usage purposes\n\tUsage       string        // usage string for help output\n\tAliases     []string      // aliases that are allowed for this flag\n\tValidator   func(T) error // custom function to validate this flag value\n\n\tOuterFlag   cli.Flag // The flag on which this inner flag will set values\n\tInnerField  string   // The inner field which this flag will set\n\tDataAliases []string // alternate names recognized in YAML values passed as the outer flag\n\n\t// OuterIsArrayOfObjects tells an untyped outer flag (Flag[any], used for nullable\n\t// complex schemas) to seed its underlying value as []map[string]any rather than\n\t// map[string]any before SetInnerField runs. The hint is ignored for typed outer\n\t// flags whose zero value already carries a dispatchable reflect.Kind.\n\tOuterIsArrayOfObjects bool\n}\n```\nInnerFlag\\[T] represents a CLI flag for the urfave/cli package that allows setting nested fields within other flags. For example, using \\`--foo.baz\\` will set the \"baz\" field on a parent flag named \\`--foo\\`.\n\n```go\nfunc (f *InnerFlag[T]) Get() any\n```\n\n```go\nfunc (f *InnerFlag[T]) GetDataAliases() []string\n```\nGetDataAliases returns the aliases recognized when parsing inner field keys from piped or flag YAML.\n\n```go\nfunc (f *InnerFlag[T]) GetDefaultText() string\n```\n\n```go\nfunc (f *InnerFlag[T]) GetEnvVars() []string\n```\n\n```go\nfunc (f *InnerFlag[T]) GetInnerField() string\n```\nGetInnerField returns the API field name that this inner flag sets on its outer flag's value. For example, the flag --parent.foo targeting a parameter whose OpenAPI property name is \"foo\" would return \"foo\". This is distinct from the flag's CLI name and from any DataAliases entries.\n\n```go\nfunc (f *InnerFlag[T]) GetOuterFlag() cli.Flag\n```\n\n```go\nfunc (f *InnerFlag[T]) GetUsage() string\n```\n\n```go\nfunc (f *InnerFlag[T]) GetValue() string\n```\n\n```go\nfunc (f *InnerFlag[T]) IsBoolFlag() bool\n```\n\n```go\nfunc (f *InnerFlag[T]) IsDefaultVisible() bool\n```\n\n```go\nfunc (f *InnerFlag[T]) IsMultiValueFlag() bool\n```\n\n```go\nfunc (f *InnerFlag[T]) IsSet() bool\n```\n\n```go\nfunc (f *InnerFlag[T]) Names() []string\n```\n\n```go\nfunc (f *InnerFlag[T]) PostParse() error\n```\n\n```go\nfunc (f *InnerFlag[T]) PreParse() error\n```\n\n```go\nfunc (f *InnerFlag[T]) Set(name string, rawVal string) error\n```\n\n```go\nfunc (f *InnerFlag[T]) SetOuterFlag(flag cli.Flag)\n```\n\n```go\nfunc (f *InnerFlag[T]) String() string\n```\n\n```go\nfunc (f *InnerFlag[T]) TakesValue() bool\n```\n\n```go\nfunc (f *InnerFlag[T]) TypeName() string\n```\n\n```go\ntype RequestContents struct {\n\tQueries map[string]any\n\tHeaders map[string]any\n\tBody    any\n}\n```\nThe values that will be sent in different parts of a request.\n\n```go\nfunc ExtractRequestContents(cmd *cli.Command) RequestContents\n```\n\n```go\ntype RequiredFlagOrStdin interface {\n\tIsRequiredAsFlagOrStdin() bool\n}\n```\n\n```go\ntype SettableInnerField interface {\n\tSetInnerField(string, any)\n}\n```\nAllow setting inner fields on other flags (e.g. --foo.baz can set the \"baz\" field on the --foo flag)\n\n```go\ntype TimeValue string\n```\n\n```go\nfunc (t *TimeValue) Parse(s string) error\n```\n\n```go\nfunc (t TimeValue) String() string\n```\n\n","path":"github.com/context-dot-dev/context-dev-cli/internal/requestflag","name":"requestflag","synopsis":"","isRedistributable":true}
