Class: Termup::Cli

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/termup/cli.rb', line 10

def source_root
  File.expand_path('../../',__FILE__)
end

Instance Method Details

#create(project) ⇒ Object



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

def create(project)
  edit(project)
end

#edit(project) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/termup/cli.rb', line 28

def edit(project)
  unless File.exists?(path(project))
    empty_directory TERMUP_DIR
    if options['iterm_advanced']
      template 'templates/iterm_advanced.yml', path(project)
    elsif options['iterm_basic']
      template 'templates/iterm_basic.yml', path(project)
    else  
      template 'templates/template.yml', path(project)
    end
  end
  say 'please set $EDITOR in ~/.bash_profile' and return unless editor = ENV['EDITOR']
  system("#{editor} #{path(project)}")
end

#listObject



44
45
46
47
# File 'lib/termup/cli.rb', line 44

def list
  projects = Dir["#{TERMUP_DIR}/*.yml"].map{|file| File.basename(file,'.yml') }
  say "Your projects: #{projects.join(', ')}"
end

#start(project) ⇒ Object



50
51
52
53
# File 'lib/termup/cli.rb', line 50

def start(project)
  say "project \"#{project}\" doesn't exist!" and return unless File.exists?(path(project))
  Termup::Base.new(project)
end