Documentation
¶
Index ¶
- type CompatibilityBehavior
- type CompatibilityFlag
- type CompatibilityFlagTranslator
- func (t *CompatibilityFlagTranslator) Translate(args []string) (atmosArgs []string, separatedArgs []string)
- func (t *CompatibilityFlagTranslator) ValidateNoConflicts(cmd *cobra.Command) error
- func (t *CompatibilityFlagTranslator) ValidateTargets(cmd *cobra.Command) error
- func (t *CompatibilityFlagTranslator) ValidateTargetsInArgs(cmd *cobra.Command, args []string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompatibilityBehavior ¶
type CompatibilityBehavior int
CompatibilityBehavior defines how a compatibility flag should be handled.
const ( // MapToAtmosFlag converts the legacy flag to a modern Atmos flag. // Example: -s → --stack, -var → --var. MapToAtmosFlag CompatibilityBehavior = iota // AppendToSeparated appends the flag and its value to separated args. // Example: -var-file → append to separated args for pass-through to terraform. AppendToSeparated )
type CompatibilityFlag ¶
type CompatibilityFlag struct {
Behavior CompatibilityBehavior
Target string // Target flag name (for MapToAtmosFlag) or empty (for AppendToSeparated)
}
CompatibilityFlag defines how a single compatibility flag should be handled.
type CompatibilityFlagTranslator ¶
type CompatibilityFlagTranslator struct {
// contains filtered or unexported fields
}
CompatibilityFlagTranslator translates legacy flag syntax to modern Cobra-compatible format. It separates args into two categories:
- atmosArgs: Args that should be parsed by Cobra (Atmos flags)
- separatedArgs: Args that should be passed through to subprocess (terraform, etc.)
func NewCompatibilityFlagTranslator ¶
func NewCompatibilityFlagTranslator(flagMap map[string]CompatibilityFlag) *CompatibilityFlagTranslator
NewCompatibilityFlagTranslator creates a new translator with the given flag map.
func (*CompatibilityFlagTranslator) Translate ¶
func (t *CompatibilityFlagTranslator) Translate(args []string) (atmosArgs []string, separatedArgs []string)
Translate processes args and separates them into Atmos args and separated args. Returns:
- atmosArgs: Arguments for Cobra to parse (Atmos flags + positional args)
- separatedArgs: Arguments to pass through to subprocess
func (*CompatibilityFlagTranslator) ValidateNoConflicts ¶
func (t *CompatibilityFlagTranslator) ValidateNoConflicts(cmd *cobra.Command) error
ValidateNoConflicts validates that compatibility flags don't conflict with Cobra native shorthands. This detects configuration errors where someone adds -s or -i to compatibility flags when they're already registered as Cobra shorthands via StringP("stack", "s", ...). This should be called after flags are registered.
func (*CompatibilityFlagTranslator) ValidateTargets ¶
func (t *CompatibilityFlagTranslator) ValidateTargets(cmd *cobra.Command) error
ValidateTargets validates that all compatibility flags with MapToAtmosFlag behavior reference flags that are actually registered on the command. This should be called after flags are registered but before parsing.
func (*CompatibilityFlagTranslator) ValidateTargetsInArgs ¶
func (t *CompatibilityFlagTranslator) ValidateTargetsInArgs(cmd *cobra.Command, args []string) error
ValidateTargetsInArgs validates that compatibility flags used in the given args reference flags that are actually registered on the command. This only validates compatibility flags that appear in the args, not all registered flags.