def command?(cmd)
      cg = MiniGit::Capturing.new
      cmd_list = cg.help :a => true
      # typical run:
      # usage: git [--version] [--help] [-C <path>] [-c name=value]
      #            [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
      #            [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
      #            [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
      #            <command> [<args>]
      #
      # available git commands in '/usr/local/Cellar/git/1.8.5.2/libexec/git-core'
      #
      #   add   [...]   \
      #   [...]          | The part we are interested in, delimited by '\n\n' sequence
      #   [...]         /
      #
      # 'git help -a' and 'git help -g' lists available subcommands and some
      # concept guides. See 'git help <command>' or 'git help <concept>'
      # to read about a specific subcommand or concept
      l = cmd_list.split("\n\n")
      l.shift # useless first part
      #ap l
      subl = l.each_index.select { |i| l[i] =~ /^\s\s+/ } # find sublines that starts with at least two whitespaces
      #ap subl
      return false if subl.empty?
      subl.any? { |i| l[i].split.include?(cmd) }
    end
def command?(cmd)
      cg = MiniGit::Capturing.new
      cmd_list = cg.help :a => true
      # typical run:
      # usage: git [--version] [--help] [-C <path>] [-c name=value]
      #            [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
      #            [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
      #            [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
      #            <command> [<args>]
      #
      # available git commands in '/usr/local/Cellar/git/1.8.5.2/libexec/git-core'
      #
      #   add   [...]   \
      #   [...]          | The part we are interested in, delimited by '\n\n' sequence
      #   [...]         /
      #
      # 'git help -a' and 'git help -g' lists available subcommands and some
      # concept guides. See 'git help <command>' or 'git help <concept>'
      # to read about a specific subcommand or concept
      l = cmd_list.split("\n\n")
      l.shift # useless first part
      #ap l
      subl = l.each_index.select { |i| l[i] =~ /^\s\s+/ } # find sublines that starts with at least two whitespaces
      #ap subl
      return false if subl.empty?
      subl.any? { |i| l[i].split.include?(cmd) }
    end
Check the availability of a given git command