Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlagInfo ¶
type FlagInfo interface {
// GetName returns the flag's name (e.g., "identity").
GetName() string
// GetShorthand returns the flag's shorthand (e.g., "i").
GetShorthand() string
// GetNoOptDefVal returns the flag's NoOptDefVal sentinel value.
GetNoOptDefVal() string
}
FlagInfo represents the information needed about a flag for preprocessing. This interface matches the methods needed from flags.Flag, avoiding circular imports.
type NoOptDefValPreprocessor ¶
type NoOptDefValPreprocessor struct {
// contains filtered or unexported fields
}
NoOptDefValPreprocessor rewrites space-separated syntax to equals syntax for flags with NoOptDefVal set.
This works around a Cobra/pflag limitation where NoOptDefVal only works with equals syntax (--flag=value), not space-separated syntax (--flag value). See: https://github.com/spf13/pflag/issues/134, pflag#321, cobra#1962
Example transformation:
Input: ["--identity", "prod", "plan"] Output: ["--identity=prod", "plan"]
Without preprocessing, "prod" would be treated as a positional argument because Cobra's NoOptDefVal assumes the user wants the default value when no equals sign is present.
func NewNoOptDefValPreprocessor ¶
func NewNoOptDefValPreprocessor(flags []FlagInfo) *NoOptDefValPreprocessor
NewNoOptDefValPreprocessor creates a new preprocessor with the given flags. The flags slice should contain all flags that may have NoOptDefVal set.
func (*NoOptDefValPreprocessor) Preprocess ¶
func (p *NoOptDefValPreprocessor) Preprocess(args []string) []string
Preprocess rewrites space-separated flag syntax to equals syntax for flags that have NoOptDefVal set.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline runs multiple preprocessors in sequence. This allows composing multiple preprocessing steps in a clear, testable manner.
func NewPipeline ¶
func NewPipeline(preprocessors ...Preprocessor) *Pipeline
NewPipeline creates a new preprocessing pipeline with the given preprocessors. Preprocessors are run in the order they are provided.
type Preprocessor ¶
type Preprocessor interface {
// Preprocess transforms args and returns the modified args.
// Implementations should not modify the input slice.
Preprocess(args []string) []string
}
Preprocessor transforms command-line arguments before Cobra parses them. This is distinct from compatibility flags (pkg/flags/compat) which translate external tool syntax like Terraform's -var.
Preprocessing handles native Atmos flag behavior that requires argument transformation before Cobra's parsing phase.