Class: Commands::Base
- Inherits:
-
Object
- Object
- Commands::Base
- Defined in:
- lib/commands/base.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#options ⇒ Object
Returns the value of attribute options.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #get(cmd) ⇒ Object
-
#initialize(input = STDIN, output = STDOUT, *args) ⇒ Base
constructor
A new instance of Base.
- #put(string, newline = true) ⇒ Object
- #run! ⇒ Object
- #sys(cmd) ⇒ Object
Constructor Details
#initialize(input = STDIN, output = STDOUT, *args) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 |
# File 'lib/commands/base.rb', line 8 def initialize(input=STDIN, output=STDOUT, *args) @input = input @output = output @options = {} parse_gitconfig parse_argv(*args) end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
6 7 8 |
# File 'lib/commands/base.rb', line 6 def input @input end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/commands/base.rb', line 6 def @options end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/commands/base.rb', line 6 def output @output end |
Instance Method Details
#get(cmd) ⇒ Object
26 27 28 29 |
# File 'lib/commands/base.rb', line 26 def get(cmd) put cmd if [:verbose] `#{cmd}` end |
#put(string, newline = true) ⇒ Object
17 18 19 |
# File 'lib/commands/base.rb', line 17 def put(string, newline=true) @output.print(newline ? string + "\n" : string) unless [:quiet] end |
#run! ⇒ Object
31 32 33 34 35 36 |
# File 'lib/commands/base.rb', line 31 def run! unless [:api_token] && [:project_id] put "Pivotal Tracker API Token and Project ID are required" return 1 end end |
#sys(cmd) ⇒ Object
21 22 23 24 |
# File 'lib/commands/base.rb', line 21 def sys(cmd) put cmd if [:verbose] system cmd end |