Skip to content

Commit

Permalink
More helpful handling of unrecognized exe/arduino_ci.rb parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfixes committed Mar 9, 2023
1 parent 2d75b6c commit 5d905ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- Fix phrasing of free-space check
- Handle unrecognized command line errors in a nicer way

### Security

Expand Down
32 changes: 22 additions & 10 deletions exe/arduino_ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@

# Use some basic parsing to allow command-line overrides of config
class Parser

def self.show_help(opts)
puts opts
puts
puts "Additionally, the following environment variables control the script:"
puts " - #{VAR_CUSTOM_INIT_SCRIPT} - if set, this script will be run from the Arduino/libraries directory"
puts " prior to any automated library installation or testing (e.g. to install unofficial libraries)"
puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd"
puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present"
puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present"
end

def self.parse(options)
unit_config = {}
output_options = {
Expand Down Expand Up @@ -58,19 +70,19 @@ def self.parse(options)
end

opts.on("-h", "--help", "Prints this help") do
puts opts
puts
puts "Additionally, the following environment variables control the script:"
puts " - #{VAR_CUSTOM_INIT_SCRIPT} - if set, this script will be run from the Arduino/libraries directory"
puts " prior to any automated library installation or testing (e.g. to install unofficial libraries)"
puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd"
puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present"
puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present"
show_help(opts)
exit
end
end

opt_parser.parse!(options)
begin
opt_parser.parse!(options)
rescue OptionParser::InvalidOption => e
puts e
puts
show_help(opt_parser)
exit 1
end
output_options
end
end
Expand Down Expand Up @@ -585,7 +597,7 @@ def perform_example_compilation_tests(cpp_library, config)
#

# Read in command line options and make them read-only
@cli_options = (Parser.parse ARGV).freeze
@cli_options = Parser.parse(ARGV).freeze

@log = ArduinoCI::Logger.auto_width
@log.banner
Expand Down

0 comments on commit 5d905ed

Please sign in to comment.