Class: Worktree::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/worktree/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean



8
9
10
# File 'lib/worktree/cli.rb', line 8

def self.exit_on_failure?
  true
end

Instance Method Details

#cherry_pick(commit) ⇒ Object



48
49
50
51
52
# File 'lib/worktree/cli.rb', line 48

def cherry_pick(commit)
  Worktree::Command::CherryPick.new(commit,
                                    to: options[:to],
                                    project_dir: options[:project_dir]).do!
end

#configureObject



55
56
57
# File 'lib/worktree/cli.rb', line 55

def configure
  Worktree::Command::Configure.new.do!
end

#new(branch) ⇒ Object



15
16
17
18
19
# File 'lib/worktree/cli.rb', line 15

def new(branch)
  Worktree::Command::Add.new(branch,
                             from: options[:from],
                             project_dir: options[:project_dir]).do!
end

#open(branch) ⇒ Object



23
24
25
26
# File 'lib/worktree/cli.rb', line 23

def open(branch)
  Worktree::Command::Open.new(branch,
                              project_dir: options[:project_dir]).do!
end

#remove(*branches) ⇒ Object



30
31
32
33
34
35
# File 'lib/worktree/cli.rb', line 30

def remove(*branches)
  branches.each do |b|
    Worktree::Command::Remove.new(b,
                                  project_dir: options[:project_dir]).do!
  end
end

#remove_staleObject



39
40
41
42
43
# File 'lib/worktree/cli.rb', line 39

def remove_stale
  Worktree::Command::RemoveStale.new(project_dir: options[:project_dir]).do!
rescue TTY::Reader::InputInterrupt
  Worktree.logger.info { "You've interrupted removing of stale branches!" }
end