Class: Pangea::CLI

Inherits:
Object show all
Defined in:
lib/pangea/cli.rb,
lib/pangea/cli/theme.rb,
lib/pangea/cli/config.rb,
lib/pangea/cli/cascade.rb,
lib/pangea/cli/operations.rb,
lib/pangea/cli/reactivity.rb,
lib/pangea/cli/orchestrate.rb,
lib/pangea/cli/synthesizer.rb,
lib/pangea/cli/tofu_events.rb

Overview

CLI for the Pangea IaC DSL.

Synthesizes Ruby templates into Terraform JSON and runs tofu operations.

pangea plan template.rb --namespace development
pangea apply template.rb --namespace production
pangea destroy template.rb --namespace development
pangea synth template.rb  # synthesis only
pangea bulk plan --namespace development  # all .rb templates in cwd
pangea orchestrate distribution.rb --backend magma

Defined Under Namespace

Modules: Orchestrate, Reactivity, Theme, TofuEvents Classes: Cascade, Config, Operations, Synthesizer

Constant Summary collapse

OPERATIONS =
%w[plan apply destroy synth output init bulk orchestrate].freeze
HELP =
<<~HELP
  Usage: pangea <operation> <template.rb> [--namespace <ns>] [--depth <n>]

  Operations:
    plan         Synthesize + tofu plan
    apply        Synthesize + tofu apply -auto-approve
    destroy      Synthesize + tofu destroy -auto-approve
    synth        Synthesize only (write JSON, no tofu)
    output       Run tofu output -json on existing workspace
    init         Synthesize + tofu init (no plan/apply)
    bulk         Run operation on all .rb templates in a directory
    orchestrate  Drive `magma flow run` over a Pangea::Magma::Orchestrator
                 / Chain / Distribution declared in the template file.
                 Flags: --backend (magma|tofu), --only foo,bar, --dry-run.

  Bulk usage:
    pangea bulk <operation> [--namespace <ns>] [--dir <path>]

  Options:
    --namespace, -n   Namespace (overrides pangea.yml default_namespace)
    --dir, -d         Directory for bulk operations (default: current dir)
    --depth, -D <n>   Cap cascade depth (0 = seed only, 1 = direct
                      neighbors, nil = unlimited). Default resolves from
                      PANGEA_CASCADE_DEPTH → workspace pangea.yml
                      cascade.default_depth → root pangea.yml same →
                      unlimited.
    --no-cascade      Run seed workspace only; same as PANGEA_NO_CASCADE=1
    --help, -h        Show this help

  Per-workspace cascade actions (pangea.yml `cascade` block):
    default_depth: N               — default depth for this workspace
    pre_actions:  [synth, output, init]  — run before primary command
    post_actions: [synth, output, init]  — run after  primary command
  Note: pre/post actions cannot name plan/apply/destroy/deploy.
HELP

Class Method Summary collapse

Class Method Details

.run(argv = ARGV.dup) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/pangea/cli.rb', line 61

def run(argv = ARGV.dup)
  operation, template_file, namespace, bulk_dir, options = parse(argv)

  case operation
  when 'bulk'
    run_bulk(template_file, namespace, bulk_dir)
  when 'orchestrate'
    Orchestrate.run(template_file, backend: options[:backend],
                    only: options[:only], dry_run: options[:dry_run])
  else
    run_single(operation, template_file, namespace, options)
  end
end