about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-07-18 12:26:12 +0200
committeraszlig <aszlig@nix.build>2018-07-19 06:35:48 +0200
commite3c58ef839b4939503cc2da8859f92e28aa3b037 (patch)
tree36345dde57ab7f0313f2f64bfc76b80ad92831a4 /pkgs/games
parent1094ee0be0dccf84dfe0fc8afae4b16286775670 (diff)
monogame-patcher: Return exitcode 1 on CLI error
If there is a command line usage error, we really don't want the program
to return exit status 0 (success), so let's actually set the return
value on WithParsed().

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/build-support/monogame-patcher/src/patcher.cs6
-rw-r--r--pkgs/games/build-support/monogame-patcher/src/test.sh9
2 files changed, 13 insertions, 2 deletions
diff --git a/pkgs/games/build-support/monogame-patcher/src/patcher.cs b/pkgs/games/build-support/monogame-patcher/src/patcher.cs
index 8e4f8ddd..bf572d9c 100644
--- a/pkgs/games/build-support/monogame-patcher/src/patcher.cs
+++ b/pkgs/games/build-support/monogame-patcher/src/patcher.cs
@@ -170,9 +170,11 @@ public class patcher {
                 settings.MaximumDisplayWidth = 80;
         });
 
+        var retval = 0;
         parser.ParseArguments<FixFileStreamsCmd, ReplaceCallCmd>(args)
             .WithParsed<FixFileStreamsCmd>(opts => new FixFileStreams(opts))
-            .WithParsed<ReplaceCallCmd>(opts => new ReplaceCall(opts));
-        return 0;
+            .WithParsed<ReplaceCallCmd>(opts => new ReplaceCall(opts))
+            .WithNotParsed(_ => retval = 1);
+        return retval;
     }
 }
diff --git a/pkgs/games/build-support/monogame-patcher/src/test.sh b/pkgs/games/build-support/monogame-patcher/src/test.sh
index a4f65aef..b7380f27 100644
--- a/pkgs/games/build-support/monogame-patcher/src/test.sh
+++ b/pkgs/games/build-support/monogame-patcher/src/test.sh
@@ -99,4 +99,13 @@ test "$(mono subdir/test2.exe)" = "can write"
 
 test "$(mono subdir/test2.exe)" = "can not write"
 
+set +e
+"$out/bin/monogame-patcher" --help &> /dev/null
+ret=$?
+set -e
+if [ $ret -eq 0 ]; then
+    echo "Running with --help should give exit status != 0 but was $ret" >&2
+    exit 1
+fi
+
 "$out/bin/monogame-patcher" --help 2>&1 | grep -q fix-filestreams