mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Update programs for getopt changes.
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.
This commit is contained in:
@@ -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)
|
||||
).
|
||||
|
||||
@@ -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))]))
|
||||
),
|
||||
|
||||
(
|
||||
|
||||
@@ -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)
|
||||
).
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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)
|
||||
).
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)} ->
|
||||
|
||||
Reference in New Issue
Block a user