Class: BuildSpecRunner::CLI
- Inherits:
-
Object
- Object
- BuildSpecRunner::CLI
- Defined in:
- lib/build_spec_runner/cli.rb
Class Method Summary collapse
-
.banner ⇒ Object
Banner for the CLI usage.
-
.main ⇒ Object
Create and execute a CLI with the default ARGV.
-
.optparse(options) ⇒ OptionParser
Create an OptParse for parsing CLI options.
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ CLI
constructor
Create a CLI object, parsing the specified argv, or ARGV if none specified.
-
#run ⇒ Object
Run the CLI object, according to the parsed options.
Constructor Details
Class Method Details
.banner ⇒ Object
Banner for the CLI usage.
67 68 69 70 71 72 73 74 |
# File 'lib/build_spec_runner/cli.rb', line 67 def self. %|Usage: #{File.basename(__FILE__)} arguments Run a build spec locally. Arguments: | end |
.main ⇒ Object
Create and execute a CLI with the default ARGV
78 79 80 |
# File 'lib/build_spec_runner/cli.rb', line 78 def self.main CLI::new.run end |
.optparse(options) ⇒ OptionParser
Create an OptParse for parsing CLI options
The options are as follows:
-
-h --help — Output help message
-
-p --path PATH — Required argument, path the to the project to run
-
-q --quiet — Silence debug messages.
-
--build_spec_path BUILD_SPEC_PATH — Alternative path for buildspec file, defaults to Runner::DEFAULT_BUILD_SPEC_PATH.
-
--profile — AWS profile of the credentials to provide the container, defaults to the default profile. This cannot be specified at the same time as --no_credentials.
-
--no_credentials — Don’t add AWS credentials to the project’s container. This cannot be specified at the same time as --profile.
-
--image_id IMAGE_ID — Id of alternative docker image to use. This cannot be specified at the same time as --aws_dockerfile_path
-
--aws_dockerfile_path AWS_DOCKERFILE_PATH — Alternative AWS CodeBuild Dockerfile path, defaults to DefaultImages::DEFAULT_DOCKERFILE_PATH. This cannot be specified at the same time as --image_id. See the AWS CodeBuild Docker Images repo for the dockerfiles available through this option.
-
--region REGION_NAME — Name of the AWS region to provide to the container. Will set environment variables to make the container appear like it is in the specified AWS region. Otherwise it defaults to the default AWS region configured in the profile.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/build_spec_runner/cli.rb', line 51 def self.optparse OptionParser.new do |opts| opts. = self.add_opt_path opts, self.add_opt_build_spec_path opts, self.add_opt_quiet opts, self.add_opt_image_id opts, self.add_opt_aws_dockerfile_path opts, self.add_opt_profile opts, self.add_opt_no_credentials opts, self.add_opt_region opts, end end |
Instance Method Details
#run ⇒ Object
Run the CLI object, according to the parsed options.
11 12 13 14 15 16 17 |
# File 'lib/build_spec_runner/cli.rb', line 11 def run source_provider = get_source_provider image = get_image raise OptionParser::InvalidOption, "Cannot specify both :profile and :no_credentials" if @options[:profile] && @options[:no_credentials] BuildSpecRunner::Runner.run image, source_provider, @options end |