diff options
Diffstat (limited to 'org')
| -rw-r--r-- | org/spine.org | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/org/spine.org b/org/spine.org index 65bebff..67574f5 100644 --- a/org/spine.org +++ b/org/spine.org @@ -61,6 +61,7 @@ string program_name = "spine"; <<spine_args_init_opts>> <<spine_args_init_settings>> <<spine_args_get_options_aa>> + <<spine_unrecognized_option>> <<spine_args_get_help>> <<read_spine_ssp_back_into_abstraction>> <<read_spine_ocda_db_back_into_abstraction>> @@ -802,6 +803,34 @@ if (opts["po4a-cfg"]) { } #+END_SRC +***** unrecognized option + +getopt runs with passThrough, so an unknown option stays among the arguments, +and the loop over sources below does not take it for one: a mistyped or retired +flag was accepted and did nothing. Done here, before any work, naming the +option; +--strict makes it fatal. + +Only options: an argument that is not a source (a README beside the pods, say) +is still passed over quietly. + +#+NAME: spine_unrecognized_option +#+BEGIN_SRC d +/+ ↓ an option getopt did not recognise +/ +{ + string[] _unknown_options + = args[1..$].filter!(a => a.length > 1 && a[0] == '-').array; + foreach (_o; _unknown_options) { + stderr.writeln("WARNING: option not recognised, ignored: ", _o); + } + if (_unknown_options.length > 0 && opts["strict"]) { + stderr.writeln("~ run FAILED ~ --strict: option not recognised"); + import core.stdc.stdlib : exit; + exit(1); + } +} +#+END_SRC + ***** help info #+NAME: spine_args_get_help |
