Class: Learn::CLI
- Inherits:
-
Thor
- Object
- Thor
- Learn::CLI
- Defined in:
- lib/learn/cli.rb
Instance Method Summary collapse
- #directory ⇒ Object
- #hello ⇒ Object
- #lint(dir = nil, quiet = nil) ⇒ Object
- #new(*lab_name) ⇒ Object
- #next ⇒ Object
- #open(*lab_name) ⇒ Object
- #reset ⇒ Object
- #save ⇒ Object
- #status ⇒ Object
- #submit(*opts) ⇒ Object
- #test(*opts) ⇒ Object
- #version ⇒ Object
- #whoami ⇒ Object
Instance Method Details
#directory ⇒ Object
95 96 97 |
# File 'lib/learn/cli.rb', line 95 def directory exec('learn-config --set-directory') end |
#hello ⇒ Object
125 126 127 |
# File 'lib/learn/cli.rb', line 125 def hello exec('learn-hello') end |
#lint(dir = nil, quiet = nil) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 |
# 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) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/learn/cli.rb', line 102 def new(*lab_name) has_internet = Learn::InternetConnection.internet_connection? template = [:template] list = [: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 ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/learn/cli.rb', line 74 def next editor = [:editor] clone_only = [:"clone-only"] command = "learn-open --next --editor=#{editor}" command << " --clone-only" if clone_only exec(command) end |
#open(*lab_name) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/learn/cli.rb', line 60 def open(*lab_name) lab_name = Learn::Lab::Parser.new(lab_name.join(' ')).parse! editor = [:editor] clone_only = [:"clone-only"] command = "learn-open #{lab_name} --editor=#{editor}" command << " --clone-only" if clone_only exec(command) end |
#reset ⇒ Object
90 91 92 |
# File 'lib/learn/cli.rb', line 90 def reset exec('learn-config --reset') end |
#save ⇒ Object
144 145 146 147 148 |
# File 'lib/learn/cli.rb', line 144 def save if !system('learn-submit --save-only') exit 1 end end |
#status ⇒ Object
120 121 122 |
# File 'lib/learn/cli.rb', line 120 def status exec('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) = if ['team'] Learn::TeamMembers::Parser.new(ARGV).execute else ['message'] end exec("learn-submit #{}") end |
#test(*opts) ⇒ Object
19 20 21 |
# File 'lib/learn/cli.rb', line 19 def test(*opts) exec("learn-test #{opts.join(' ')}") end |
#whoami ⇒ Object
85 86 87 |
# File 'lib/learn/cli.rb', line 85 def whoami exec('learn-config --whoami') end |