Class: HerokuAppInfo::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku_app_info/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.

Parameters:

  • argv (Array)


8
9
10
11
12
# File 'lib/heroku_app_info/options.rb', line 8

def initialize(argv)
  defaults!
  @parser = cli_parser
  @rest = @parser.parse(argv)
end

Instance Attribute Details

#appsObject (readonly)

Returns the value of attribute apps.



13
14
15
# File 'lib/heroku_app_info/options.rb', line 13

def apps
  @apps
end

#authzObject (readonly)

Returns the value of attribute authz.



13
14
15
# File 'lib/heroku_app_info/options.rb', line 13

def authz
  @authz
end

#out_dirObject (readonly)

Returns the value of attribute out_dir.



13
14
15
# File 'lib/heroku_app_info/options.rb', line 13

def out_dir
  @out_dir
end

#restObject (readonly)

Returns the value of attribute rest.



13
14
15
# File 'lib/heroku_app_info/options.rb', line 13

def rest
  @rest
end

Instance Method Details

#cli_parserOptionParser

Returns:

  • (OptionParser)


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
# File 'lib/heroku_app_info/options.rb', line 44

def cli_parser
  OptionParser.new do |opt|
    opt.on("-a", "--app-list APP,APP,APP") do |apps|
      @apps = apps.split(",")
    end
    opt.on("--app-list-from FILE") do |file|
      if File.exist?(file) && File.readable?(file)
        @apps = File.read(file).lines(chomp: true)
      end
    end
    opt.on("-n", "--no-cache") do
      @no_cache = true
    end
    opt.on("-o", "--out-dir [DIR]") do |dir|
      if File.exist?(dir) && File.directory?(dir) && File.writable?(dir)
        @out_dir = dir
      end
    end
    opt.on("-r", "--raw-output") do
      @raw_output = true
    end
    opt.on("-s", "--show-all-apps", "not include detail") do
      @show_all = true
    end
    opt.on("-z", "--authorizarion AUTH") do |auth|
      @authz = auth
    end

    opt.version = VERSION
  end
end

#defaults!Object



33
34
35
# File 'lib/heroku_app_info/options.rb', line 33

def defaults!
  @out_dir = Dir.pwd
end

#helpObject



37
38
39
# File 'lib/heroku_app_info/options.rb', line 37

def help
  @parser.help
end

#no_cache?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/heroku_app_info/options.rb', line 25

def no_cache?
  @no_cache
end

#raw_output?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/heroku_app_info/options.rb', line 29

def raw_output?
  @raw_output
end

#show_all?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/heroku_app_info/options.rb', line 18

def show_all?
  @show_all
end