Class: Braid::Command

Inherits:
Object
  • Object
show all
Extended by:
Operations::VersionControl, T::Sig
Includes:
Operations::VersionControl
Defined in:
lib/braid/command.rb

Defined Under Namespace

Classes: InvalidRevision

Class Method Summary collapse

Instance Method Summary collapse

Methods included from T::Sig

sig

Methods included from Operations::VersionControl

git, git_cache

Class Method Details

.handle_error(error) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/braid/command.rb', line 24

def self.handle_error(error)
  case error
    when Operations::ShellExecutionError
      msg "Shell error: #{error.message}"
    else
      msg "Error: #{error.message}"
  end
  exit(1)
end

.msg(str) ⇒ Object



35
36
37
# File 'lib/braid/command.rb', line 35

def self.msg(str)
  puts "Braid: #{str}"
end

.run(command, *args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/braid/command.rb', line 12

def self.run(command, *args)
  verify_git_version!
  check_working_dir!

  klass = Commands.const_get(command.to_s)
  klass.new.run(*args)

rescue BraidError => error
  handle_error(error)
end

Instance Method Details

#configObject



45
46
47
# File 'lib/braid/command.rb', line 45

def config
  @config ||= Config.new({'mode' => config_mode})
end

#force?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/braid/command.rb', line 55

def force?
  Braid.force
end

#msg(str) ⇒ Object



40
41
42
# File 'lib/braid/command.rb', line 40

def msg(str)
  self.class.msg(str)
end

#verbose?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/braid/command.rb', line 50

def verbose?
  Braid.verbose
end