Class: Icarus::Mod::CLI::Add
Overview
Sync CLI command definitions
Instance Method Summary
collapse
banner, subcommand_prefix
Methods inherited from Base
exit_on_failure?
Instance Method Details
#mod ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/icarus/mod/cli/add.rb', line 37
def mod
firestore = Firestore.new
data = options[:modinfo]
if data.nil? || !File.exist?(data)
warn "Invalid data file: #{data}"
exit 1
end
JSON.parse(File.read(data), symbolize_names: true)[:mods].each do |mod|
modinfo = Icarus::Mod::Tools::Modinfo.new(mod)
unless modinfo.valid?
warn "Invalid modinfo: #{modinfo.errors}"
exit 1
end
puts firestore.update(:mod, modinfo, merge: true) ? "Success" : "Failure"
end
end
|
#modinfo(item) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/icarus/mod/cli/add.rb', line 12
def modinfo(item)
firestore = Firestore.new
payload = [firestore.modinfo, item].flatten.compact
puts firestore.update(:modinfo, payload, merge: true) ? "Success" : "Failure"
end
|
#repos(item) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/icarus/mod/cli/add.rb', line 28
def repos(item)
firestore = Firestore.new
payload = [firestore.repositories, item].flatten.compact
puts firestore.update(:repositories, payload, merge: true) ? "Success" : "Failure"
end
|
20
21
22
23
24
25
|
# File 'lib/icarus/mod/cli/add.rb', line 20
def toolinfo(item)
firestore = Firestore.new
payload = [firestore.toolinfo, item].flatten.compact
puts firestore.update(:toolinfo, payload, merge: true) ? "Success" : "Failure"
end
|