Class: Sfn::Command::Print
- Inherits:
-
Sfn::Command
- Object
- Bogo::Cli::Command
- Sfn::Command
- Sfn::Command::Print
- Defined in:
- lib/sfn/command/print.rb
Overview
Print command
Constant Summary
Constants included from Sfn::CommandModule::Template
Sfn::CommandModule::Template::MAX_PARAMETER_ATTEMPTS, Sfn::CommandModule::Template::TEMPLATE_IGNORE_DIRECTORIES
Constants inherited from Sfn::Command
CONFIG_BASE_NAME, VALID_CONFIG_EXTENSIONS
Instance Method Summary collapse
-
#execute! ⇒ Object
Print the requested template.
Methods included from Sfn::CommandModule::Stack
Methods included from Sfn::CommandModule::Template
Methods included from Sfn::CommandModule::Base
Methods inherited from Sfn::Command
Methods included from Sfn::CommandModule::Callbacks
#api_action!, #callbacks_for, #run_callbacks_for
Constructor Details
This class inherits a constructor from Sfn::Command
Instance Method Details
#execute! ⇒ Object
Print the requested template
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sfn/command/print.rb', line 14 def execute! config[:print_only] = true file = load_template_file json_content = format_json(parameter_scrub!(template_content(file))) if(config[:write_to_file]) unless(File.directory?(File.dirname(config[:write_to_file]))) run_action 'Creating parent directory' do FileUtils.mkdir_p(File.dirname(config[:write_to_file])) nil end end run_action "Writing template to file - #{config[:write_to_file]}" do File.write(config[:write_to_file], json_content) nil end else ui.puts json_content end end |