Class: Termrc::Cli

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create

  if File.exist? '.termrc'
    raise Thor::Error.new "Error: '.termrc' already exists!"
  else
    say "Creating .termrc file..", :yellow
    FileUtils.cp TERMRC_TEMPLATE, '.termrc'

    say "Success! \n\n", :yellow

    say "Now run your new termrc file by calling `termrc start`", :blue
  end
end

#list(folder = '.') ⇒ Object



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

def list(folder='.')
  folder_description = folder == "." ? 'current folder' : "'#{folder}'"
  say "Looking for termrc files in #{folder_description}:", :yellow
  
  a = `find #{folder} | grep -w \.termrc$`
  say a

  say "None found.", :red if a.length < 1
end

#start(file = false) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/termrc/cli.rb', line 42

def start(file=false)
  file = file || '.termrc'
  raise Thor::Error.new "File '#{file}'' does not exist!" unless File.exist? file

  say "Starting termrc file: '#{file}'.", :yellow
  say "[ Please wait until fully launched! ]", :red
  begin
    Termrc::Base.new( File.expand_path(file) )
  rescue Exception => e
    say "\nError while starting termrc file:", :red
    puts e
  end
end