Class: ThreeScaleToolbox::Commands::PlansCommand::Export::ExportSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/plans_command/export_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #keep_alive, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/3scale_toolbox/commands/plans_command/export_command.rb', line 8

def self.command
  Cri::Command.define do
    name        'export'
    usage       'export [opts] <remote> <service_system_name> <plan_system_name>'
    summary     'export application plan'
    description 'Export application plan, limits, pricing rules and features'

    option      :f, :file, 'Write to file instead of stdout', argument: :required
    param       :remote
    param       :service_system_name
    param       :plan_system_name

    runner ExportSubcommand
  end
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
# File 'lib/3scale_toolbox/commands/plans_command/export_command.rb', line 24

def run
  select_output do |output|
    plan_object = application_plan.to_hash.merge(
      'created_at' => Time.now.utc.iso8601,
      'toolbox_version' => ThreeScaleToolbox::VERSION
    )
    output.write(plan_object.to_yaml)
  end
end