class Git::Commands::Base

@api private

Base class for git command implementations.

Provides default {#initialize} and {#call} methods so that simple commands only need to declare their arguments:

class Add < Git::Commands::Base
  arguments do
    literal 'add'
    flag_option :all
    flag_option :force
    end_of_options
    operand :paths, repeatable: true
  end

  # Execute the git add command
  # ...YARD docs...
  def call(...) = super
end

Commands whose git process may exit with a non-zero status that is not an error can declare the acceptable range of exit codes:

class Delete < Git::Commands::Base
  arguments do
    literal 'branch'
    literal '--delete'
    operand :branch_names, repeatable: true, required: true
  end

  allow_exit_status 0..1

  # Execute the git branch --delete command
  # ...YARD docs...
  def call(...) = super
end

Commands with execution options (e.g., timeout) work with the default ‘call` — execution options are extracted and forwarded automatically.