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
292
293
294
|
# File 'lib/enfcli.rb', line 292
def __print_version
puts EnfCli::VERSION
end
|
#connect(*names) ⇒ Object
250
251
252
253
254
255
256
257
258
259
260
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
|
# File 'lib/enfcli.rb', line 250
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
316
317
318
319
320
321
322
323
|
# File 'lib/enfcli.rb', line 316
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
327
328
329
330
331
332
333
334
|
# File 'lib/enfcli.rb', line 327
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
306
307
308
309
310
|
# File 'lib/enfcli.rb', line 306
def search
cmd = Gem::Commands::SearchCommand.new
cmd.handle_options ["enfcli"]
execute_gem_cmd cmd
end
|
#update ⇒ Object
298
299
300
301
302
|
# File 'lib/enfcli.rb', line 298
def update
cmd = Gem::Commands::UpdateCommand.new
cmd.handle_options ["enfcli"]
execute_gem_cmd cmd
end
|