Class: EnfCli::CLI
Overview
Instance Method Summary
collapse
Methods inherited from EnfThor
capture_stdout, command_help, handle_argument_error, help
Instance Method Details
#__print_version ⇒ Object
303
304
305
|
# File 'lib/enfcli.rb', line 303
def __print_version
puts EnfCli::VERSION
end
|
#connect(*names) ⇒ Object
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
# File 'lib/enfcli.rb', line 261
def connect(*names)
host = ""
user = ""
try_with_rescue do
if options[:host] && options[:user]
host = options[:host]
user = options[:user]
elsif File.file?(CONFIG_FILE) config_json = JSON.load(File.open(CONFIG_FILE))
host = config_json["host"]
user = config_json["user"]
else
raise EnfCli::ERROR, "You must either specify the --host and --user parameters or create a Xaptum config file to connect."
end
host = "https://#{host}" unless host =~ /^(http|https):\/\//
say "Connecting to '#{host}'.....", :bold
password = EnfCli::ask_password()
resp = EnfApi::API.instance.authenticate(host, user, password)
EnfCli::CTX.instance.init host, user, resp[:data][0]
if names.empty?
EnfCli::Shell::Console::start
else
EnfCli::Shell::CLI.start names
end
end
end
|
#create_config_file ⇒ Object
327
328
329
330
331
332
333
334
|
# File 'lib/enfcli.rb', line 327
def create_config_file
host = options[:host]
user = options[:user]
config_file = File.new(CONFIG_FILE, "w+")
config_file.puts({ host: host, user: user }.to_json)
config_file.close
say "Config file created successfully at #{CONFIG_FILE}!", :green
end
|
#display_config_file ⇒ Object
338
339
340
341
342
343
344
345
|
# File 'lib/enfcli.rb', line 338
def display_config_file
file = CONFIG_FILE
raise EnfCli::ERROR, "#{file} not found!" unless File.exists?(file)
say File.readlines(file).join
end
|
#search ⇒ Object
317
318
319
320
321
|
# File 'lib/enfcli.rb', line 317
def search
cmd = Gem::Commands::SearchCommand.new
cmd.handle_options ["enfcli"]
execute_gem_cmd cmd
end
|
#update ⇒ Object
309
310
311
312
313
|
# File 'lib/enfcli.rb', line 309
def update
cmd = Gem::Commands::UpdateCommand.new
cmd.handle_options ["enfcli"]
execute_gem_cmd cmd
end
|