Skip to content

Commit

Permalink
add - doc - Added the "version" parameter
Browse files Browse the repository at this point in the history
---

We've added a new parameter that allows you to get the kernel version straight from one command line argument without having to parse the file. The API version can also be get this way.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Aug 14, 2024
1 parent 330fe94 commit 675836a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
11 changes: 9 additions & 2 deletions public/Nitrocid/Arguments/ArgumentParse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ namespace Nitrocid.Arguments
public static class ArgumentParse
{

private readonly static string[] outArgs =
[
"help",
"version",
"apiversion"
];

/// <summary>
/// Available command line arguments
/// </summary>
Expand Down Expand Up @@ -220,7 +227,7 @@ public static bool IsArgumentPassed(string[] ArgumentsInput, string argumentName
{
string Argument = ArgumentsInput[i];
string ArgumentName = Argument.SplitEncloseDoubleQuotes()[0];
found = ArgumentName == "help" || ArgumentName == argumentName && Arguments.ContainsKey(ArgumentName);
found = ArgumentName == argumentName && (outArgs.Contains(ArgumentName) || Arguments.ContainsKey(ArgumentName));
if (found)
break;
}
Expand All @@ -237,7 +244,7 @@ public static bool IsArgumentPassed(string[] ArgumentsInput, string argumentName
private static string[] GetFilteredArguments(string[] ArgumentsInput)
{
if (ArgumentHelpPrint.acknowledged)
ArgumentsInput = ArgumentsInput.Where((arg) => arg != "help").ToArray();
ArgumentsInput = ArgumentsInput.Where((arg) => !outArgs.Contains(arg)).ToArray();
return ArgumentsInput;
}

Expand Down
15 changes: 14 additions & 1 deletion public/Nitrocid/Kernel/KernelMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
using Terminaux.Base;
using Terminaux.Base.Extensions;
using Nitrocid.Kernel.Configuration;
using Terminaux.Writer.ConsoleWriters;

namespace Nitrocid.Kernel
{
Expand Down Expand Up @@ -89,7 +90,7 @@ internal static void Main(string[] Args)
// Set main thread name
Thread.CurrentThread.Name = "Main Nitrocid Kernel Thread";

// Show help prior to starting the kernel if help is passed
// Show help / version prior to starting the kernel if help / version is passed
if (ArgumentParse.IsArgumentPassed(Args, "help"))
{
// Kernel arguments
Expand All @@ -98,6 +99,18 @@ internal static void Main(string[] Args)
PowerManager.hardShutdown = true;
PowerManager.KernelShutdown = true;
}
else if (ArgumentParse.IsArgumentPassed(Args, "version"))
{
TextWriterRaw.WritePlain(VersionFullStr);
PowerManager.hardShutdown = true;
PowerManager.KernelShutdown = true;
}
else if (ArgumentParse.IsArgumentPassed(Args, "apiversion"))
{
TextWriterRaw.WritePlain($"{ApiVersion}");
PowerManager.hardShutdown = true;
PowerManager.KernelShutdown = true;
}

// This is a kernel entry point
EnvironmentTools.kernelArguments = Args;
Expand Down
8 changes: 8 additions & 0 deletions public/Nitrocid/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
"Nitrocid KS - Help system for cmdline args": {
"commandName": "Project",
"commandLineArgs": "help"
},
"Nitrocid KS - version": {
"commandName": "Project",
"commandLineArgs": "version"
},
"Nitrocid KS - apiversion": {
"commandName": "Project",
"commandLineArgs": "apiversion"
}
}
}

0 comments on commit 675836a

Please sign in to comment.