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

Constructor Details

#initializeCommand

Returns a new instance of Command.



38
39
40
# File 'lib/braid/command.rb', line 38

def initialize
  @config = T.let(nil, T.nilable(Config))
end

Class Method Details

.handle_error(error) ⇒ Object



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

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



33
34
35
# File 'lib/braid/command.rb', line 33

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

Instance Method Details

#configObject



48
49
50
# File 'lib/braid/command.rb', line 48

def config
  @config ||= Config.new(mode: config_mode)
end

#force?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/braid/command.rb', line 58

def force?
  Braid.force
end

#msg(str) ⇒ Object



43
44
45
# File 'lib/braid/command.rb', line 43

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

#runObject



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

def run
  verify_git_version!
  check_working_dir!
  run_internal
rescue BraidError => error
  Command.handle_error(error)
end

#verbose?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/braid/command.rb', line 53

def verbose?
  Braid.verbose
end