Class: Fav::RunCommand
- Inherits:
-
FavCommand
- Object
- FavCommand
- Fav::RunCommand
- Defined in:
- lib/fav.rb
Overview
Run a command specified as a Fav.
Instance Attribute Summary
Attributes inherited from FavCommand
#cli_options, #command_args, #command_name, #command_options, #config, #favs_file
Instance Method Summary collapse
-
#on_group(group) ⇒ Object
Run grouped command.
-
#on_non_group ⇒ Object
Run non-grouped command.
Methods inherited from FavCommand
#initialize, #post_group, #run!
Constructor Details
This class inherits a constructor from Fav::FavCommand
Instance Method Details
#on_group(group) ⇒ Object
Run grouped command
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/fav.rb', line 76 def on_group(group) # If we are running a grouped command, we must check if we are running the entire group or an individual command within a group. if self.command_name run_cmd self.config[group][self.command_name] else input = self.[:no_prompt] ? 'C' : 'N' self.config[group].each do |key, value| # don't re-prompt if they have chosen to continue input = ask "Run command: #{value}? [(Y)es, (N)o, (C)ontinue, (B)reak]" unless input == 'C' case input when 'Y', 'C' sh value when 'B' info 'Breaking the execution of all remaining commands in group.' break else #'N' or some unrecognized option info "Skipping the execution of #{value}" end end end end |
#on_non_group ⇒ Object
Run non-grouped command
99 100 101 102 |
# File 'lib/fav.rb', line 99 def on_non_group CommandFactory.command_name_check(self.command_name, 'Running') run_cmd self.config[self.command_name] end |