Module: PopulateEnv::CLI::HerokuOptions

Defined in:
lib/populate_env/cli/heroku_options.rb

Class Method Summary collapse

Class Method Details

.parse(argv, command:, options: PopulateEnv::Heroku::Options.new) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
# File 'lib/populate_env/cli/heroku_options.rb', line 8

def parse(argv, command:, options: PopulateEnv::Heroku::Options.new)
  parser = OptionParser.new

  parser.accept(Pathname) { |path| Pathname(path) }

  parser.banner = "Usage: #{command} [options]"

  description = "Path to the app.json schema (defaults to #{options.manifest})"
  parser.on("--manifest FILE", Pathname, description) do |value|
    options.manifest = value
  end
  
  description = "File to write (defaults to #{options.destination})"
  parser.on("--destination FILE", Pathname, description) do |value|
    options.destination = value
  end

  description = "Environment to read from the app.json manifest (defaults to #{options.manifest_environment})"
  parser.on("-e", "--manifest-environment ENVIRONMENT", description) do |value|
    options.manifest_environment = value
  end

  description = "Skip environment variables currently set in your shell (defaults to #{options.skip_local_env})"
  parser.on("--[no-]skip-local-env", description) do |value|
    options.skip_local_env = value
  end
  
  description = "Populate missing environment variables from Heroku (defaults to #{options.use_heroku_config})"
  parser.on("--[no-]heroku-config", description) do |value|
    options.use_heroku_config = value
  end
  
  description = 'Heroku remote to use for reading config'
  parser.on("--heroku-remote GIT_REMOTE", description) do |value|
    options.heroku_remote = value
  end
  
  description = 'Heroku app to use for reading config'
  parser.on("--heroku-app APP_NAME", description) do |value|
    options.heroku_app = value
  end
  
  description = 'Whether to generate secrets'
  parser.on("--[no-]generate-secrets", description) do |value|
    options.generate_secrets = value
  end
  
  description = "Prompt the user for missing environment variables (defaults to #{options.prompt_missing})"
  parser.on("--[no-]prompt-missing", description) do |value|
    options.prompt_missing = value
  end

  description = "Prefix variable declarations in output with export (defaults to #{options.skip_local_env})"
  parser.on("--[no-]export", description) do |value|
    options.export = value
  end

  parser.parse!(argv)

  options
end