Module: Formatron::CLI::Destroy
- Defined in:
- lib/formatron/cli/destroy.rb
Overview
CLI command for destroy
Instance Method Summary collapse
- #destroy_action(c) ⇒ Object
- #destroy_credentials(options) ⇒ Object
- #destroy_directory(options) ⇒ Object
- #destroy_formatron_command ⇒ Object
- #destroy_ok(options, formatron, target) ⇒ Object
- #destroy_target(target, directory) ⇒ Object
Instance Method Details
#destroy_action(c) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/formatron/cli/destroy.rb', line 34 def destroy_action(c) c.action do |args, | directory = destroy_directory target = destroy_target args[0], directory formatron = Formatron.new( credentials: destroy_credentials(), directory: directory, target: target ) formatron.destroy if destroy_ok , formatron, target end end |
#destroy_credentials(options) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/formatron/cli/destroy.rb', line 12 def destroy_credentials() .credentials || Generators::Credentials.default_credentials( destroy_directory() ) end |
#destroy_directory(options) ⇒ Object
8 9 10 |
# File 'lib/formatron/cli/destroy.rb', line 8 def destroy_directory() .directory || Dir.pwd end |
#destroy_formatron_command ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/formatron/cli/destroy.rb', line 47 def destroy_formatron_command command :destroy do |c| c.syntax = 'formatron destroy [options] [TARGET]' c.summary = 'Destroy a Formatron stack' c.description = 'Destroy a Formatron stack' destroy_action c end end |
#destroy_ok(options, formatron, target) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/formatron/cli/destroy.rb', line 26 def destroy_ok(, formatron, target) .yes || !formatron.protected? || agree( "Are you sure you wish to destroy protected target: #{target}?" ) do |q| q.default = 'no' end end |