class Learn::CLI

Public Instance Methods

directory() click to toggle source
# File lib/learn/cli.rb, line 95
def directory
  exec('learn-config --set-directory')
end
hello() click to toggle source
# File lib/learn/cli.rb, line 125
def hello
  exec('learn-hello')
end
lint(dir=nil, quiet=nil) click to toggle source
# File lib/learn/cli.rb, line 130
def lint(dir=nil, quiet=nil)
  if dir && !quiet
    exec("learn-lint #{dir}")
  elsif dir && quiet
    exec("learn-lint #{dir} #{quiet}")
  elsif !dir && quiet
    exec("learn-lint #{quiet}")
  else
    current_dir = Dir.pwd
    exec("learn-lint #{current_dir}")
  end
end
new(*lab_name) click to toggle source
# File lib/learn/cli.rb, line 102
def new(*lab_name)
  has_internet = Learn::InternetConnection.internet_connection?
  template = options[:template]
  list = options[:list]

  if list
    exec("learn-generate --list #{has_internet ? '--internet' : ''}")
  else
    if template && template != 'template'
      exec("learn-generate #{template} #{lab_name.join} #{has_internet ? '--internet' : ''}")
    else
      puts "You must specify a template with -t or --template"
      exit
    end
  end
end
next() click to toggle source
# File lib/learn/cli.rb, line 74
def next
  editor = options[:editor]
  clone_only = options[:"clone-only"]

  command = "learn-open --next --editor=#{editor}"
  command << " --clone-only" if clone_only

  exec(command)
end
open(*lab_name) click to toggle source
# File lib/learn/cli.rb, line 60
def open(*lab_name)
  lab_name = Learn::Lab::Parser.new(lab_name.join(' ')).parse!
  editor = options[:editor]
  clone_only = options[:"clone-only"]

  command = "learn-open #{lab_name} --editor=#{editor}"
  command << " --clone-only" if clone_only

  exec(command)
end
reset() click to toggle source
# File lib/learn/cli.rb, line 90
def reset
  exec('learn-config --reset')
end
save() click to toggle source
# File lib/learn/cli.rb, line 144
def save
  if !system('learn-submit --save-only')
    exit 1
  end
end
status() click to toggle source
# File lib/learn/cli.rb, line 120
def status
  exec('learn-status')
end
submit(*opts) click to toggle source
# File lib/learn/cli.rb, line 38
def submit(*opts)
  commit_message = if options['team']
    Learn::TeamMembers::Parser.new(ARGV).execute
  else
    options['message']
  end

  exec("learn-submit #{commit_message}")
end
test(*opts) click to toggle source
# File lib/learn/cli.rb, line 19
def test(*opts)
  exec("learn-test #{opts.join(' ')}")
end
version() click to toggle source
# File lib/learn/cli.rb, line 24
def version
  puts Learn::VERSION
end
whoami() click to toggle source
# File lib/learn/cli.rb, line 85
def whoami
  exec('learn-config --whoami')
end