50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/mmi/interactive/assets.rb', line 50
def create_source
source_type = CLI::UI::Prompt.ask('Choose a source type.') do |handler|
%w[
github
modrinth
url
].each do |type|
handler.option(type, &:to_sym)
end
handler.option('quit', &:to_sym)
end
source =
case source_type
when :quit
return false
when :github
options = {
'type' => 'github',
'asset_id' => 0,
}
options['owner' ] = CLI::UI::Prompt.ask('Who is the owner of the source repository?').strip
options['repo' ] = CLI::UI::Prompt.ask('What is the name of the source repository?').strip
options['install_dir'] = CLI::UI::Prompt.ask('In which directory should the asset be placed?', default: 'mods').strip
options['filename' ] = CLI::UI::Prompt.ask('Under which filename should the asset be saved? (leave empty for release asset name)', allow_empty: true).strip.then do |filename|
filename == '' ? nil : filename
end
options.compact!
Mmi::Source::Github.parse(options)
when :modrinth
options = {
'type' => 'modrinth',
'version' => '0',
'version_file' => '0',
}
options['name' ] = CLI::UI::Prompt.ask('What is the name of the mod in the Modrinth URL?').strip
options['install_dir'] = CLI::UI::Prompt.ask('In which directory should the asset be placed?', default: 'mods').strip
options['filename' ] = CLI::UI::Prompt.ask('Under which filename should the asset be saved? (leave empty for release asset name)', allow_empty: true).strip.then do |filename|
filename == '' ? nil : filename
end
options.compact!
Mmi::Source::Modrinth.parse(options)
when :url
options = {
'type' => 'url',
}
options['install_dir'] = CLI::UI::Prompt.ask('In which directory should the asset be placed?', default: 'mods').strip
options['filename' ] = CLI::UI::Prompt.ask('Under which filename should the asset be saved? (leave empty for release asset name)', allow_empty: true).strip.then do |filename|
filename == '' ? nil : filename
end
options.compact!
Mmi::Source::Url.parse(options)
end
if update_asset_source_version(source)
source
else
nil
end
end
|