Class: Learn::CLI

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

Instance Method Summary collapse

Instance Method Details

#directoryObject



85
86
87
# File 'lib/learn/cli.rb', line 85

def directory
  system('learn-config --set-directory')
end

#doctorObject



90
91
92
# File 'lib/learn/cli.rb', line 90

def doctor
  system('learn-doctor')
end

#helloObject



120
121
122
# File 'lib/learn/cli.rb', line 120

def hello
  system('learn-hello')
end

#lint(dir = nil, quiet = nil) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/learn/cli.rb', line 125

def lint(dir=nil, quiet=nil)
  if dir && !quiet
    system("learn-lint #{dir}")
  elsif dir && quiet
    system("learn-lint #{dir} #{quiet}")
  elsif !dir && quiet
    system("learn-lint #{quiet}")
  else
    current_dir = Dir.pwd
    system("learn-lint #{current_dir}")
  end
end

#new(*lab_name) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/learn/cli.rb', line 97

def new(*lab_name)
  has_internet = Learn::InternetConnection.internet_connection?
  template = options[:template]
  list = options[:list]

  if list
    system("learn-generate --list #{has_internet ? '--internet' : ''}")
  else
    if template && template != 'template'
      system("learn-generate #{template} #{lab_name.join} #{has_internet ? '--internet' : ''}")
    else
      puts "You must specify a template with -t or --template"
      exit
    end
  end
end

#nextObject



68
69
70
71
72
# File 'lib/learn/cli.rb', line 68

def next
  editor = options[:editor]

  system("learn-open --next --editor=#{editor}")
end

#open(*lab_name) ⇒ Object



59
60
61
62
63
64
# File 'lib/learn/cli.rb', line 59

def open(*lab_name)
  lab_name = Learn::Lab::Parser.new(lab_name.join(' ')).parse!
  editor = options[:editor]

  system("learn-open #{lab_name} --editor=#{editor}")
end

#resetObject



80
81
82
# File 'lib/learn/cli.rb', line 80

def reset
  system('learn-config --reset')
end

#saveObject



139
140
141
142
143
# File 'lib/learn/cli.rb', line 139

def save
  if !system('learn-submit --save-only')
    exit 1
  end
end

#statusObject



115
116
117
# File 'lib/learn/cli.rb', line 115

def status
  system('learn-status')
end

#submit(*opts) ⇒ Object



38
39
40
41
42
43
44
45
46
# 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

  system("learn-submit #{commit_message}")
end

#test(*opts) ⇒ Object



19
20
21
# File 'lib/learn/cli.rb', line 19

def test(*opts)
  system("learn-test #{opts.join(' ')}")
end

#versionObject



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

def version
  puts Learn::VERSION
end

#whoamiObject



75
76
77
# File 'lib/learn/cli.rb', line 75

def whoami
  system('learn-config --whoami')
end