Module: Clue::CLI
- Included in:
- Clue
- Defined in:
- lib/clue/cli.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#dry_run ⇒ Object
(also: #dry_run?)
Verbose, dry run readers & aliases.
-
#verbose ⇒ Object
(also: #verbose?)
Verbose, dry run readers & aliases.
Instance Method Summary collapse
-
#call ⇒ Object
Print and/or execute command.
-
#cli_command ⇒ Object
Command as a string.
-
#cli_command_array ⇒ Object
Command as an array.
-
#print ⇒ Object
Print command.
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
4 5 6 |
# File 'lib/clue/cli.rb', line 4 def command @command end |
#dry_run ⇒ Object Also known as: dry_run?
Verbose, dry run readers & aliases
7 8 9 |
# File 'lib/clue/cli.rb', line 7 def dry_run @dry_run end |
#verbose ⇒ Object Also known as: verbose?
Verbose, dry run readers & aliases
7 8 9 |
# File 'lib/clue/cli.rb', line 7 def verbose @verbose end |
Instance Method Details
#call ⇒ Object
Print and/or execute command
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/clue/cli.rb', line 40 def call raise ArgumentError, 'a command is expected' unless @command before_call if self.respond_to?(:before_call) print if dry_run? || verbose? system(cli_command) unless dry_run? after_call if self.respond_to?(:after_call) end |
#cli_command ⇒ Object
Command as a string
30 31 32 |
# File 'lib/clue/cli.rb', line 30 def cli_command cli_command_array.join(' ') end |
#cli_command_array ⇒ Object
Command as an array
23 24 25 26 27 |
# File 'lib/clue/cli.rb', line 23 def cli_command_array [@command, , cli_arguments, cli_streams].each_with_object([]) do |string, memo| memo << string if string && string != '' end end |
#print ⇒ Object
Print command
35 36 37 |
# File 'lib/clue/cli.rb', line 35 def print puts cli_command end |