tokiwa-software / fuzion

The Fuzion Language Implementation
https://fuzion-lang.dev
GNU General Public License v3.0
47 stars 11 forks source link

fz_cmd: check for invalid values in provided options #4159

Closed simonvonhackewitz closed 2 days ago

simonvonhackewitz commented 4 days ago

fix #4156

examples

❯ fz -XmaxErrors -e 'say "ok"' 
ok

❯ fz -XmaxErrors=twenty -e 'say "ok"'

error 1: 'twenty' is not a valid argument to option '-XmaxErrors'. Please provide a integer value or use the option without an argument for unlimited errors.
Usage: /home/simon/fuzion/build/bin/fz [-h|--help|-version]  --or--
       /home/simon/fuzion/build/bin/fz [-c|-classes|-dfa|-effects|-frontend-only|-interpreter|-jar|-java|-jvm|-llvm|-no-backend|-saveLib=<file>] [-h|--help|-version] [<backend specific options>]  --or--
       /home/simon/fuzion/build/bin/fz -pretty [-noANSI] [-verbose[=<n>]]  ({<file>} | - | -e <code> | -execute <code>)  --or--
       /home/simon/fuzion/build/bin/fz -latex [-noANSI] [-verbose[=<n>]]   --or--
       /home/simon/fuzion/build/bin/fz -acemode [-noANSI] [-verbose[=<n>]]   --or--

*** fatal errors encountered, stopping.
one error.

❯ fz -XmaxWarnings=5.0 -e 'say "ok"'

error 1: '5.0' is not a valid argument to option '-XmaxWarnings'. Please provide a integer value or use the option without an argument for unlimited warnings.
Usage: /home/simon/fuzion/build/bin/fz [-h|--help|-version]  --or--
       /home/simon/fuzion/build/bin/fz [-c|-classes|-dfa|-effects|-frontend-only|-interpreter|-jar|-java|-jvm|-llvm|-no-backend|-saveLib=<file>] [-h|--help|-version] [<backend specific options>]  --or--
       /home/simon/fuzion/build/bin/fz -pretty [-noANSI] [-verbose[=<n>]]  ({<file>} | - | -e <code> | -execute <code>)  --or--
       /home/simon/fuzion/build/bin/fz -latex [-noANSI] [-verbose[=<n>]]   --or--
       /home/simon/fuzion/build/bin/fz -acemode [-noANSI] [-verbose[=<n>]]   --or--

*** fatal errors encountered, stopping.
one error.

❯ fz -XjavaProf= -e 'say "ok"'      

error 1: Please provide a file name to option '-XjavaProf=<file>'.
Usage: /home/simon/fuzion/build/bin/fz [-h|--help|-version]  --or--
       /home/simon/fuzion/build/bin/fz [-c|-classes|-dfa|-effects|-frontend-only|-interpreter|-jar|-java|-jvm|-llvm|-no-backend|-saveLib=<file>] [-h|--help|-version] [<backend specific options>]  --or--
       /home/simon/fuzion/build/bin/fz -pretty [-noANSI] [-verbose[=<n>]]  ({<file>} | - | -e <code> | -execute <code>)  --or--
       /home/simon/fuzion/build/bin/fz -latex [-noANSI] [-verbose[=<n>]]   --or--
       /home/simon/fuzion/build/bin/fz -acemode [-noANSI] [-verbose[=<n>]]   --or--

*** fatal errors encountered, stopping.
one error.