|
19 | 19 |
|
20 | 20 | # Use some basic parsing to allow command-line overrides of config
|
21 | 21 | class Parser
|
| 22 | + |
| 23 | + def self.show_help(opts) |
| 24 | + puts opts |
| 25 | + puts |
| 26 | + puts "Additionally, the following environment variables control the script:" |
| 27 | + puts " - #{VAR_CUSTOM_INIT_SCRIPT} - if set, this script will be run from the Arduino/libraries directory" |
| 28 | + puts " prior to any automated library installation or testing (e.g. to install unofficial libraries)" |
| 29 | + puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd" |
| 30 | + puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present" |
| 31 | + puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present" |
| 32 | + end |
| 33 | + |
22 | 34 | def self.parse(options)
|
23 | 35 | unit_config = {}
|
24 | 36 | output_options = {
|
@@ -58,19 +70,19 @@ def self.parse(options)
|
58 | 70 | end
|
59 | 71 |
|
60 | 72 | opts.on("-h", "--help", "Prints this help") do
|
61 |
| - puts opts |
62 |
| - puts |
63 |
| - puts "Additionally, the following environment variables control the script:" |
64 |
| - puts " - #{VAR_CUSTOM_INIT_SCRIPT} - if set, this script will be run from the Arduino/libraries directory" |
65 |
| - puts " prior to any automated library installation or testing (e.g. to install unofficial libraries)" |
66 |
| - puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd" |
67 |
| - puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present" |
68 |
| - puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present" |
| 73 | + show_help(opts) |
69 | 74 | exit
|
70 | 75 | end
|
71 | 76 | end
|
72 | 77 |
|
73 |
| - opt_parser.parse!(options) |
| 78 | + begin |
| 79 | + opt_parser.parse!(options) |
| 80 | + rescue OptionParser::InvalidOption => e |
| 81 | + puts e |
| 82 | + puts |
| 83 | + show_help(opt_parser) |
| 84 | + exit 1 |
| 85 | + end |
74 | 86 | output_options
|
75 | 87 | end
|
76 | 88 | end
|
@@ -585,7 +597,7 @@ def perform_example_compilation_tests(cpp_library, config)
|
585 | 597 | #
|
586 | 598 |
|
587 | 599 | # Read in command line options and make them read-only
|
588 |
| -@cli_options = (Parser.parse ARGV).freeze |
| 600 | +@cli_options = Parser.parse(ARGV).freeze |
589 | 601 |
|
590 | 602 | @log = ArduinoCI::Logger.auto_width
|
591 | 603 | @log.banner
|
|
0 commit comments