[m-rev.] diff: Update programs for getopt changes.
Peter Wang
novalazy at gmail.com
Mon Oct 26 16:24:49 AEDT 2020
benchmarks/progs/icfp2000_par/main.m:
benchmarks/progs/mandelbrot/mandelbrot.m:
benchmarks/tools/log_to_r/log_to_r.m:
extras/align_right/align_right.m:
extras/error/error.m:
extras/gator/evolve.m:
extras/moose/options.m:
samples/concurrency/midimon/midimon.m:
samples/diff/diff.m:
samples/muz/muz.m:
Conform to getopt.process_options now returning structured errors
instead of strings.
diff --git a/benchmarks/progs/icfp2000_par/main.m b/benchmarks/progs/icfp2000_par/main.m
index 4d8aabe07..37f513a69 100644
--- a/benchmarks/progs/icfp2000_par/main.m
+++ b/benchmarks/progs/icfp2000_par/main.m
@@ -70,8 +70,8 @@ main(!IO) :-
true
)
;
- OptionResult = error(Msg),
- io.write_string(Msg, !IO),
+ OptionResult = error(Error),
+ io.write_string(option_error_to_string(Error), !IO),
io.nl(!IO),
io.set_exit_status(1, !IO)
).
diff --git a/benchmarks/progs/mandelbrot/mandelbrot.m b/benchmarks/progs/mandelbrot/mandelbrot.m
index d4635f99b..78c45a3dc 100644
--- a/benchmarks/progs/mandelbrot/mandelbrot.m
+++ b/benchmarks/progs/mandelbrot/mandelbrot.m
@@ -58,7 +58,7 @@ main(!IO) :-
;
GetoptResult = error(Error),
Result = error(format("Error processing options: %s\n",
- [s(Error)]))
+ [s(option_error_to_string(Error))]))
),
(
diff --git a/benchmarks/tools/log_to_r/log_to_r.m b/benchmarks/tools/log_to_r/log_to_r.m
index de558e5da..e71ffc5a9 100644
--- a/benchmarks/tools/log_to_r/log_to_r.m
+++ b/benchmarks/tools/log_to_r/log_to_r.m
@@ -28,8 +28,8 @@ main(!IO) :-
command_line_arguments(Args, !IO),
OptionOpts = option_ops_multi(short, long, defaults),
getopt.process_options(OptionOpts, Args, InputFiles, MaybeOptions),
-(
- MaybeOptions = ok(Options),
+ (
+ MaybeOptions = ok(Options),
getopt.lookup_bool_option(Options, help_option, HelpOption),
( HelpOption = yes ->
io.stdout_stream(Stdout, !IO),
@@ -61,8 +61,8 @@ main(!IO) :-
;
MaybeOptions = error(Error),
io.stderr_stream(Stderr, !IO),
- io.write_string(Stderr, "Error passing command line options: " ++ Error,
- !IO),
+ io.write_string(Stderr, "Error passing command line options: " ++
+ option_error_to_string(Error), !IO),
show_help(Stderr, !IO),
io.set_exit_status(1, !IO)
).
diff --git a/extras/align_right/align_right.m b/extras/align_right/align_right.m
index d1c0ff874..63138635a 100644
--- a/extras/align_right/align_right.m
+++ b/extras/align_right/align_right.m
@@ -44,9 +44,9 @@ main(!IO) :-
getopt.process_options(OptionOps, Args, _OptionArgs, NonOptionArgs,
OptionsResult),
(
- OptionsResult = error(ErrorMsg),
+ OptionsResult = error(Error),
set_exit_status(1, !IO),
- io.write_string(ErrorMsg, !IO),
+ io.write_string(option_error_to_string(Error), !IO),
io.nl(!IO)
;
OptionsResult = ok(OptionTable),
diff --git a/extras/error/error.m b/extras/error/error.m
index b774e7be9..67954ce5b 100644
--- a/extras/error/error.m
+++ b/extras/error/error.m
@@ -91,8 +91,8 @@ main(!IO) :-
OptionOps = option_ops_multi(short_options, long_options, option_defaults),
getopt.process_options(OptionOps, Args0, Args, GetoptResult),
(
- GetoptResult = error(ErrorMessage),
- io.write_string(ErrorMessage, !IO),
+ GetoptResult = error(Error),
+ io.write_string(option_error_to_string(Error), !IO),
io.set_exit_status(1, !IO)
;
GetoptResult = ok(OptionTable),
diff --git a/extras/gator/evolve.m b/extras/gator/evolve.m
index 49d530ed7..170fb19b3 100644
--- a/extras/gator/evolve.m
+++ b/extras/gator/evolve.m
@@ -78,8 +78,8 @@ main(!IO) :-
getopt.lookup_int_option(OptionTable, second_seed, SecondSeed),
getopt.lookup_int_option(OptionTable, third_seed, ThirdSeed)
;
- Result = error(ErrorMessage),
- require.error(ErrorMessage)
+ Result = error(Error),
+ require.error(option_error_to_string(Error))
),
% Read the input files.
diff --git a/extras/moose/options.m b/extras/moose/options.m
index 746997a6c..5453ff5a1 100644
--- a/extras/moose/options.m
+++ b/extras/moose/options.m
@@ -49,7 +49,8 @@
parse_options(MOpts, Args, !IO) :-
io.command_line_arguments(Args0, !IO),
OptionOpts = option_ops_multi(short, long, defaults),
- getopt.process_options(OptionOpts, Args0, Args, MOpts).
+ getopt.process_options(OptionOpts, Args0, Args, MOpts0),
+ MOpts = convert_to_maybe_option_table(MOpts0).
:- pred short(char::in, option::out) is semidet.
diff --git a/samples/concurrency/midimon/midimon.m b/samples/concurrency/midimon/midimon.m
index d7e81176a..69450a1f8 100644
--- a/samples/concurrency/midimon/midimon.m
+++ b/samples/concurrency/midimon/midimon.m
@@ -62,9 +62,9 @@ main(!IO) :-
)
)
;
- MOpts = error(Msg),
+ MOpts = error(Error),
io.stderr_stream(StdErr, !IO),
- io.format(StdErr, "%s\n", [s(Msg)], !IO),
+ io.format(StdErr, "%s\n", [s(option_error_to_string(Error))], !IO),
io.set_exit_status(1, !IO)
).
diff --git a/samples/diff/diff.m b/samples/diff/diff.m
index 9effa25d6..0b5356510 100644
--- a/samples/diff/diff.m
+++ b/samples/diff/diff.m
@@ -43,7 +43,8 @@ main(!IO) :-
io.command_line_arguments(Args0, !IO),
options.get_option_ops(OptionOps),
getopt.process_options(OptionOps, Args0, Args, Result0),
- postprocess_options(Result0, Result, !IO),
+ Result1 = convert_to_maybe_option_table(Result0),
+ postprocess_options(Result1, Result, !IO),
(
Result = yes(Msg),
usage_error(Msg, !IO)
diff --git a/samples/muz/muz.m b/samples/muz/muz.m
index f22f740a2..7fcda8a12 100644
--- a/samples/muz/muz.m
+++ b/samples/muz/muz.m
@@ -81,7 +81,7 @@ main -->
io__command_line_arguments(AL0),
{getopt__process_options(Option_Ops, AL0, AL, Maybe_Option_Table)},
( {Maybe_Option_Table = error(Message)},
- zmessage("muz", [Message]),
+ zmessage("muz", [option_error_to_string(Message)]),
usage
; {Maybe_Option_Table = ok(Option_Table)},
( {getopt__lookup_bool_option(Option_Table, help, yes)} ->
--
2.28.0
More information about the reviews
mailing list