Class: Octokom::Command
- Includes:
- Shell
- Defined in:
- lib/octokom/command.rb
Direct Known Subclasses
Class Method Summary collapse
-
.execute(&block) ⇒ Object
Override ‘Clamp::Command.execute` method so it can be used as a block.
-
.flag(tags, desc, &block) ⇒ Object
Shortcut for ‘Clamp::Command.option` with `:flag` argument.
-
.option_with_type(tags, desc, &block) ⇒ Object
Alias for the ‘Clamp::Command.option` method that uses the long option tag as type string.
Instance Method Summary collapse
- #authenticate {|Octokom::Client.authenticate| ... } ⇒ Object
-
#git ⇒ Object
Initializes a new Repository instance that is available in all Octokom::Command instances.
Methods included from Shell
Class Method Details
.execute(&block) ⇒ Object
Override ‘Clamp::Command.execute` method so it can be used as a block.
35 36 37 38 39 |
# File 'lib/octokom/command.rb', line 35 def self.execute(&block) define_method(:execute, block) do yield if block_given? end end |
.flag(tags, desc, &block) ⇒ Object
Shortcut for ‘Clamp::Command.option` with `:flag` argument.
For example:
flag ['-a'], A option'
Is the same as:
option ['-a'], :flag, 'A option'
17 18 19 |
# File 'lib/octokom/command.rb', line 17 def self.flag(, desc, &block) option_without_type(, :flag, desc, &block) end |
.option_with_type(tags, desc, &block) ⇒ Object
29 30 31 32 |
# File 'lib/octokom/command.rb', line 29 def self.option_with_type(, desc, &block) type = .first[/^--(.*)$/, 1].upcase option_without_type(, type, desc, &block) end |
Instance Method Details
#authenticate {|Octokom::Client.authenticate| ... } ⇒ Object
66 67 68 |
# File 'lib/octokom/command.rb', line 66 def authenticate(&block) yield Octokom::Client.authenticate end |
#git ⇒ Object
Initializes a new Repository instance that is available in all Octokom::Command instances.
62 63 64 |
# File 'lib/octokom/command.rb', line 62 def git @git ||= Octokom::Repository.new(verbose?) end |