Class: Trout::CLI
- Inherits:
-
Object
- Object
- Trout::CLI
- Defined in:
- lib/trout/cli.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#command ⇒ Object
Returns the value of attribute command.
-
#file_attributes ⇒ Object
Returns the value of attribute file_attributes.
-
#managed_files ⇒ Object
Returns the value of attribute managed_files.
-
#option_parser ⇒ Object
Returns the value of attribute option_parser.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(arguments) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(arguments) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 |
# File 'lib/trout/cli.rb', line 13 def initialize(arguments) self.arguments = arguments self.file_attributes = {} self.option_parser = self.managed_files = VersionList.new('.trout') end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
11 12 13 |
# File 'lib/trout/cli.rb', line 11 def arguments @arguments end |
#command ⇒ Object
Returns the value of attribute command.
11 12 13 |
# File 'lib/trout/cli.rb', line 11 def command @command end |
#file_attributes ⇒ Object
Returns the value of attribute file_attributes.
11 12 13 |
# File 'lib/trout/cli.rb', line 11 def file_attributes @file_attributes end |
#managed_files ⇒ Object
Returns the value of attribute managed_files.
11 12 13 |
# File 'lib/trout/cli.rb', line 11 def managed_files @managed_files end |
#option_parser ⇒ Object
Returns the value of attribute option_parser.
11 12 13 |
# File 'lib/trout/cli.rb', line 11 def option_parser @option_parser end |
Class Method Details
.run(arguments) ⇒ Object
7 8 9 |
# File 'lib/trout/cli.rb', line 7 def self.run(arguments) new(arguments).run end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/trout/cli.rb', line 20 def run case command when 'checkout' file_attributes[:filename] = next_argument file_attributes[:git_url] = next_argument file = ManagedFile.new(file_attributes) end_arguments file.checkout managed_files << file when 'update' file = managed_files[next_argument] end_arguments file.update managed_files << file when 'help', nil puts option_parser if arguments_left? puts usage_for(next_argument) end else unknown_command(command) end end |