30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
|
# File 'lib/alfi/cli.rb', line 30
def create_options_parser
@all_defined_arguments = [
'-u',
'--user',
'-k',
'--key',
'-r',
'--repository',
'-h',
'--help',
'-v',
'--version',
'-p',
'--prefix',
'-s',
'--single-quotes'
]
@opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: alfi SEARCH_QUERY [OPTIONS]"
opts.separator ''
opts.separator 'Options'
opts.on('-u BINTRAY_USER_NAME', '--user BINTRAY_USER_NAME', 'your bintray user name') do |bintray_username|
@bintray_username = bintray_username
end
opts.on('-k BINTRAY_KEY', '--key BINTRAY_KEY', 'your bintray api key') do |bintray_key|
@bintray_key = bintray_key
end
opts.on('-h', '--help', 'Displays help') do
puts opts.help
exit
end
opts.on('-v', '--version', 'Displays version') do
puts Alfi::VERSION
exit
end
opts.on('-p PREFIX', '--prefix PREFIX', 'Use custom prefix instead of "implementation"') do |prefix|
$prefix = prefix
end
opts.on('-s', '--single-quotes', 'Use single quotes instead of double quotes') do
$single_quotes = true
end
opts.on('-r REPOSITORY_NAME', '--repository REPOSITORY_NAME', 'If should search on maven, jCenter or mavenCentral ') do |repository_name|
if repository_name != "maven" && repository_name != "jcenter" && repository_name != "mavencentral"
puts "Please choose one of the following maven, jcenter or mavencentral"
exit
end
if repository_name.downcase == "maven"
@search_type << "m"
end
if repository_name.downcase == "mavencentral"
@search_type << "maven"
end
if repository_name.downcase == "jcenter"
@search_type << "jcenter"
end
end
opts.separator "\nNow you are using alfi credentials for Bintray".yellow
opts.separator "But you also could enter your authentication data if you want. "\
"It will be saved once you provided it\n".green unless @bintray_username
end
end
|