27
28
29
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
|
# File 'lib/dotenv-android/cli.rb', line 27
def parse_options
Dotenv.load('.env')
options = Options.new
options.verbose = false
options.debug = false
opt_parser = OptionParser.new do |opts|
opts.banner = 'Usage: dotenv-android [options]'
opts.on('-v', '--version', 'Print version') do
puts DotEnvAndroid::Version.get
exit
end
opts.on('-s', '--source DIR', 'Source code directory to check for requested environment variables') do |source|
options.source = source
options.out = Pathname.new(source).join('Env.kt') end
opts.on('--verbose', 'Verbose output') do
options.verbose = true
end
opts.on('--debug', 'Debug output (also turns on verbose)') do
options.verbose = true
options.debug = true
end
opts.on('--package', 'Package name to add to the top of the generated Env.kt file (example: com.yourdomain.app, or PACKAGE_NAME environment variable found in .env)') do |package_name| options.package_name = package_name
end
opts.on('-o', '--out FILE', 'Output file (example: Path/Env.kt)') do |out|
options.out = out
end
opts.on('-h', '--help', 'Prints this help') do
puts opts
exit
end
end
help = opt_parser.help
abort(help) if ARGV.empty?
opt_parser.parse!(ARGV)
if options.package_name.nil?
options.package_name = ENV["PACKAGE_NAME"]
@ui.fail("Cannot find package name in .env file with key, PACKAGE_NAME, or as a CLI argument") if options.package_name.nil?
end
options
end
|