Class: Pik::Remove
- Includes:
- ConfigFileEditor
- Defined in:
- lib/pik/commands/remove_command.rb
Instance Attribute Summary collapse
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
Attributes inherited from Command
#config, #debug, #options, #output, #version
Instance Method Summary collapse
Methods included from ConfigFileEditor
Methods inherited from Command
#actual_gem_home, #add_sigint_handler, aka, choose_from, #close, cmd_name, #cmd_name, #create, #current_gem_bin_path, #current_version?, #default_gem_home, #delete_old_pik_script, description, #editors, #find_config_from_path, #gem_path, #get_version, hl, inherited, #initialize, it, names, #parse_options, #pik_version, #sh, summary
Instance Attribute Details
#force ⇒ Object (readonly)
Returns the value of attribute force.
9 10 11 |
# File 'lib/pik/commands/remove_command.rb', line 9 def force @force end |
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
9 10 11 |
# File 'lib/pik/commands/remove_command.rb', line 9 def quiet @quiet end |
Instance Method Details
#command_options ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/pik/commands/remove_command.rb', line 20 def super .on("--force", "-f", "Remove without prompting") do |value| @force = value end .on("--quiet", "-q", "Remove without a response") do |value| @quiet = value end end |
#execute ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/pik/commands/remove_command.rb', line 11 def execute to_remove = self.class.choose_from(@args, @config) raise QuitError unless to_remove if force || @hl.agree("Are you sure you'd like to remove '#{to_remove}'?"){|answer| answer.default = 'yes' } @config.delete(to_remove) @hl.say("#{to_remove} removed.") unless quiet end end |