module GitFlow::Mixin

Public Instance Methods

execute(opt, argv) click to toggle source

Override this method in your command class to implement the command. First argument is the openstruct object after it has been populated by the option parser. Second argument is the array of non-option arguments.

# File lib/git_bpf/lib/gitflow.rb, line 222
def execute(opt, argv)
  fail "#{self.class.command} not implemented"
end
expand_path(path, dir=Dir.pwd) click to toggle source
# File lib/git_bpf/lib/gitflow.rb, line 255
def expand_path(path, dir=Dir.pwd)
  File.expand_path(path, dir)
end
git(*args) click to toggle source
# File lib/git_bpf/lib/gitflow.rb, line 241
def git(*args)
  cmd = 'git ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
  trace cmd
  `#{cmd}`.tap {
    fail "GIT command `#{cmd}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
  }
end
options(opt) click to toggle source

Override this method in your command class if it needs to parse command line options.

This method takes an openstruct object as argument allowing you to store default values on it, and set option values.

The return value must be an array of arguments given to optparse.on

# File lib/git_bpf/lib/gitflow.rb, line 213
def options(opt)
  []
end
page() { || ... } click to toggle source

Yield paging the blocks output if necessary.

# File lib/git_bpf/lib/gitflow.rb, line 232
def page
  GitFlow.pager
  yield
end
run(*argv, &block) click to toggle source

Run the command line given on argv

# File lib/git_bpf/lib/gitflow.rb, line 227
def run(*argv, &block)
  GitFlow.run(*argv, &block)
end
sh(*args) click to toggle source
# File lib/git_bpf/lib/gitflow.rb, line 249
def sh(*args)
  `#{args.join(' ')}`.tap {
    fail "Shell command `#{args.join(' ')}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
  }
end
trace(*str) click to toggle source
# File lib/git_bpf/lib/gitflow.rb, line 237
def trace(*str)
  STDERR.puts(*str) if GitFlow.trace
end