2026-02-17 09:56:24 -05:00
|
|
|
// Copyright IBM Corp. 2014, 2026
|
2026-02-13 08:43:54 -05:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
|
|
|
|
package arguments
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/hashicorp/terraform/internal/tfdiags"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// StatePull represents the command-line arguments for the state pull command.
|
|
|
|
|
type StatePull struct {
|
2026-03-13 12:20:20 -04:00
|
|
|
// Vars are the variable-related flags (-var, -var-file).
|
|
|
|
|
Vars *Vars
|
2026-02-13 08:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ParseStatePull processes CLI arguments, returning a StatePull value and
|
|
|
|
|
// diagnostics. If errors are encountered, a StatePull value is still returned
|
|
|
|
|
// representing the best effort interpretation of the arguments.
|
|
|
|
|
func ParseStatePull(args []string) (*StatePull, tfdiags.Diagnostics) {
|
|
|
|
|
var diags tfdiags.Diagnostics
|
2026-03-13 12:20:20 -04:00
|
|
|
pull := &StatePull{
|
|
|
|
|
Vars: &Vars{},
|
|
|
|
|
}
|
2026-02-13 08:43:54 -05:00
|
|
|
|
2026-03-13 12:20:20 -04:00
|
|
|
cmdFlags := extendedFlagSet("state pull", nil, nil, pull.Vars)
|
2026-02-13 08:43:54 -05:00
|
|
|
|
|
|
|
|
if err := cmdFlags.Parse(args); err != nil {
|
|
|
|
|
diags = diags.Append(tfdiags.Sourceless(
|
|
|
|
|
tfdiags.Error,
|
|
|
|
|
"Failed to parse command-line flags",
|
|
|
|
|
err.Error(),
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pull, diags
|
|
|
|
|
}
|