Class: ConfigureS3Website::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/configure-s3-website/cli.rb

Class Method Summary collapse

Class Method Details

.optparse_and_optionsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/configure-s3-website/cli.rb', line 3

def self.optparse_and_options
  options = {}
  optparse = OptionParser.new do |opts|
    opts.banner = banner
    opts.on('--headless',
            'Run without interaction from the user. See the --autocreate-cloudfront-dist for more info.') do
      options[:headless] = true
    end
    opts.on('--autocreate-cloudfront-dist',
            'When running with --headless, automatically create a CloudFront distribution for your S3 website.') do
      options['autocreate-cloudfront-dist'] = true
    end
    opts.on('-f', '--config-file FILE',
            'Pick credentials and the S3 bucket name from a config file') do
            |yaml_file_path|
      options[:config_source] =
        ConfigureS3Website::FileConfigSource.new yaml_file_path
    end
    opts.on('-v', '--verbose', 'Print more stuff') do
      options[:verbose] = true
    end
    opts.on('--help', 'Display this screen') do
      puts opts
      exit
    end
  end
  [options, optparse]
end