aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/diffable
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-10-23 08:41:00 +0200
committerBjörn Gustavsson <[email protected]>2018-10-23 08:43:24 +0200
commit9ebb7a3b087423774ee45becaa4305a7af37adf6 (patch)
tree9ab7416261919f495470879834ec891204b9312f /scripts/diffable
parentd5ad94075c7b8e396f780aba55c70363ce4738c4 (diff)
downloadotp-9ebb7a3b087423774ee45becaa4305a7af37adf6.tar.gz
otp-9ebb7a3b087423774ee45becaa4305a7af37adf6.tar.bz2
otp-9ebb7a3b087423774ee45becaa4305a7af37adf6.zip
scripts/diffable: Refactor option parsing
Diffstat (limited to 'scripts/diffable')
-rwxr-xr-xscripts/diffable27
1 files changed, 17 insertions, 10 deletions
diff --git a/scripts/diffable b/scripts/diffable
index 6a9792e857..66b50d0499 100755
--- a/scripts/diffable
+++ b/scripts/diffable
@@ -8,8 +8,7 @@ main(Args0) ->
[OutDir] ->
do_compile(OutDir, Opts);
_ ->
- usage(),
- halt(1)
+ usage()
end.
usage() ->
@@ -42,17 +41,25 @@ usage() ->
"# Hack ops.tab and/or one of the *instr.tab files.\n"
"$ scripts/diffable --dis --no-compile new\n"
"$ diff -u old new\n",
- io:put_chars(S).
-
-opts(["--asm"|Args], Opts) ->
- opts(Args, Opts#{format:=asm});
-opts(["--dis"|Args], Opts) ->
- opts(Args, Opts#{format:=dis});
-opts(["--no-compile"|Args], Opts) ->
- opts(Args, Opts#{format:=dis,no_compile:=true});
+ io:put_chars(S),
+ halt(1).
+
+opts(["--"++Opt|Args], Opts0) ->
+ Opts = opt(Opt, Opts0),
+ opts(Args, Opts);
opts(Args, Opts) ->
{Args,Opts}.
+opt("asm", Opts) ->
+ Opts#{format:=asm};
+opt("dis", Opts) ->
+ Opts#{format:=dis};
+opt("no-compile", Opts) ->
+ Opts#{format:=dis,no_compile:=true};
+opt(Opt, Opts) ->
+ io:format("Uknown option: --~ts\n\n", [Opt]),
+ usage().
+
do_compile(OutDir, Opts0) ->
Opts1 = Opts0#{outdir=>OutDir},
_ = filelib:ensure_dir(filename:join(OutDir, "dummy")),