Class: Octokom::Command

Inherits:
Clamp::Command
  • Object
show all
Includes:
Shell
Defined in:
lib/octokom/command.rb

Direct Known Subclasses

Issue, CLI, PullRequest

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shell

#error, #info, #task

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(tags, desc, &block)
  option_without_type(tags, :flag, desc, &block)
end

.option_with_type(tags, desc, &block) ⇒ Object

Alias for the ‘Clamp::Command.option` method that uses the long option tag as type string.

For example:

Octokom::Command.option ['-a', '--abc'], 'ABC option'

Is the same as:

Clamp::Command.option ['-a', '--abc'], 'ABC', 'ABC option'


29
30
31
32
# File 'lib/octokom/command.rb', line 29

def self.option_with_type(tags, desc, &block)
  type = tags.first[/^--(.*)$/, 1].upcase
  option_without_type(tags, 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

#gitObject

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