From f0a6b2d65fe5ad7189065667c0928660092e0a08 Mon Sep 17 00:00:00 2001 From: mika-n <35538525+mika-n@users.noreply.github.com> Date: Tue, 24 Nov 2020 20:50:08 +0200 Subject: [PATCH] tweaked return values (1000 as error code) --- Program.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index 81d3ec2..697edc9 100644 --- a/Program.cs +++ b/Program.cs @@ -136,6 +136,11 @@ static void Main(string[] args) Console.WriteLine("This DS4WindowsCmd.exe app was created just to send commands to the background host app and make it easier"); Console.WriteLine("to integrate with batch scripts."); Console.WriteLine(""); + Console.WriteLine("RETURN VALUE: Commands return results in errorlevel variable and as a console text output."); + Console.WriteLine("RETURN VALUE: If the text output is True or False boolean string then errorlevel is also set to 1 or 0."); + Console.WriteLine("RETURN VALUE: Query.Battery option outputs the battery level as text and sets errorlevel to 0-100."); + Console.WriteLine("RETURN VALUE: If there was an error then output is empty and errorlevel is set to 1000."); + Console.WriteLine(""); Console.WriteLine("USAGE: "); Console.WriteLine("DS4WindowsCmd.exe -command Start | Stop | Shutdown (start/stop controllers or shutdown the background app)"); Console.WriteLine(""); @@ -238,8 +243,15 @@ static void Main(string[] args) } if (bDoSendMsg == false) - Environment.ExitCode = 100; // Something went wrong with Query.xxx cmd. The cmd was not sent, so return error status 100 - else if (strResult.ToLower() == "true") + Environment.ExitCode = 1000; // Something went wrong with Query.xxx cmd. The cmd was not sent, so return error status 1000 + else if (args[1].ToLower().StartsWith("query.") && args[1].ToLower().EndsWith(".battery")) + { + int iBatteryLevel = 1000; + if(!int.TryParse(strResult, out iBatteryLevel)) + iBatteryLevel = 1000; + Environment.ExitCode = iBatteryLevel; + } + else if (strResult.ToLower() == "true") Environment.ExitCode = 1; else Environment.ExitCode = 0;