Class: Loca::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/loca/cli.rb

Instance Method Summary collapse

Instance Method Details

#__print_versionObject



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

def __print_version
  puts Loca::VERSION
end

#c(pasted_url) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/loca/cli.rb', line 14

def c(pasted_url)
  return d(pasted_url) if options[:delete]

  git = Loca::Git.new(pasted_url)
  branch_name = git.branch_name

  if git.first_time_creating? || yes?("WARN: Branch '#{branch_name}' "\
    ' already exists. Overwrite? (n)', :yellow)
    git.fetch
    git.checkout
    say "Checked out #{branch_name}!", :green
  else
    fail Loca::Error::GitAborted, 'Git checkout aborted!'
  end
end

#d(pasted_url) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/loca/cli.rb', line 31

def d(pasted_url)
  git = Loca::Git.new(pasted_url)
  branch_name = git.branch_name

  git.delete
  say "Deleted #{branch_name}!", :green
end