Skip to content

Commit

Permalink
add - doc - Added infinite indicator
Browse files Browse the repository at this point in the history
---

We've added infinite indicator for command arguments.

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 24, 2024
1 parent 2ce1baa commit 94232c9
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 20 deletions.
2 changes: 1 addition & 1 deletion public/Nitrocid/Nitrocid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<NitrocidModAPIVersionMajor>3.0.25</NitrocidModAPIVersionMajor>

<!-- Increment NitrocidModAPIVersionChangeset every time there is a breaking change or an API addition in the N-KS API. -->
<NitrocidModAPIVersionChangeset>432</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>433</NitrocidModAPIVersionChangeset>

<!-- To be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
61 changes: 54 additions & 7 deletions public/Nitrocid/Shell/ShellBase/Arguments/CommandArgumentInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class CommandArgumentInfo
/// </summary>
public bool AcceptsSet { get; private set; }
/// <summary>
/// Whether to accept infinite number of arguments
/// </summary>
public bool InfiniteBounds { get; private set; }
/// <summary>
/// Rendered usage
/// </summary>
public string RenderedUsage
Expand Down Expand Up @@ -119,6 +123,8 @@ public string RenderedUsage
$"{requiredTagStart}{Argument.ArgumentExpression}{numericRender}{requiredTagEnd} ";
usageBuilder.Append(renderedArgument);
}
string infiniteIndicator = InfiniteBounds ? "..." : "";
usageBuilder.Append(infiniteIndicator);

return usageBuilder.ToString().Trim();
}
Expand All @@ -128,23 +134,32 @@ public string RenderedUsage
/// Installs a new instance of the command argument info class
/// </summary>
public CommandArgumentInfo()
: this([], [], false)
: this([], [], false, false)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
public CommandArgumentInfo(bool AcceptsSet)
: this([], [], AcceptsSet)
: this([], [], AcceptsSet, false)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
/// <param name="infiniteBounds">Whether to accept infinite number of arguments or not</param>
public CommandArgumentInfo(bool AcceptsSet, bool infiniteBounds)
: this([], [], AcceptsSet, infiniteBounds)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="Arguments">Command arguments</param>
public CommandArgumentInfo(CommandArgumentPart[] Arguments)
: this(Arguments, [], false)
: this(Arguments, [], false, false)
{ }

/// <summary>
Expand All @@ -153,15 +168,25 @@ public CommandArgumentInfo(CommandArgumentPart[] Arguments)
/// <param name="Arguments">Command arguments</param>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
public CommandArgumentInfo(CommandArgumentPart[] Arguments, bool AcceptsSet)
: this(Arguments, [], AcceptsSet)
: this(Arguments, [], AcceptsSet, false)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="Arguments">Command arguments</param>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
/// <param name="infiniteBounds">Whether to accept infinite number of arguments or not</param>
public CommandArgumentInfo(CommandArgumentPart[] Arguments, bool AcceptsSet, bool infiniteBounds)
: this(Arguments, [], AcceptsSet, infiniteBounds)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="Switches">Command switches</param>
public CommandArgumentInfo(SwitchInfo[] Switches)
: this([], Switches, false)
: this([], Switches, false, false)
{ }

/// <summary>
Expand All @@ -170,7 +195,17 @@ public CommandArgumentInfo(SwitchInfo[] Switches)
/// <param name="Switches">Command switches</param>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
public CommandArgumentInfo(SwitchInfo[] Switches, bool AcceptsSet)
: this([], Switches, AcceptsSet)
: this([], Switches, AcceptsSet, false)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="Switches">Command switches</param>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
/// <param name="infiniteBounds">Whether to accept infinite number of arguments or not</param>
public CommandArgumentInfo(SwitchInfo[] Switches, bool AcceptsSet, bool infiniteBounds)
: this([], Switches, AcceptsSet, infiniteBounds)
{ }

/// <summary>
Expand All @@ -179,7 +214,7 @@ public CommandArgumentInfo(SwitchInfo[] Switches, bool AcceptsSet)
/// <param name="Arguments">Command arguments</param>
/// <param name="Switches">Command switches</param>
public CommandArgumentInfo(CommandArgumentPart[] Arguments, SwitchInfo[] Switches)
: this(Arguments, Switches, false)
: this(Arguments, Switches, false, false)
{ }

/// <summary>
Expand All @@ -189,6 +224,17 @@ public CommandArgumentInfo(CommandArgumentPart[] Arguments, SwitchInfo[] Switche
/// <param name="Switches">Command switches</param>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
public CommandArgumentInfo(CommandArgumentPart[] Arguments, SwitchInfo[] Switches, bool AcceptsSet)
: this(Arguments, Switches, AcceptsSet, false)
{ }

/// <summary>
/// Installs a new instance of the command argument info class
/// </summary>
/// <param name="Arguments">Command arguments</param>
/// <param name="Switches">Command switches</param>
/// <param name="AcceptsSet">Whether to accept the -set switch or not</param>
/// <param name="infiniteBounds">Whether to accept infinite number of arguments or not</param>
public CommandArgumentInfo(CommandArgumentPart[] Arguments, SwitchInfo[] Switches, bool AcceptsSet, bool infiniteBounds)
{
var finalArgs = Arguments ?? [];
var finalSwitches = Switches ?? [];
Expand All @@ -198,6 +244,7 @@ public CommandArgumentInfo(CommandArgumentPart[] Arguments, SwitchInfo[] Switche
else
this.Switches = finalSwitches;
this.AcceptsSet = AcceptsSet;
InfiniteBounds = infiniteBounds;
}

}
Expand Down
24 changes: 12 additions & 12 deletions public/Nitrocid/Shell/Shells/UESH/UESHShellInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
new CommandArgumentPart(true, "answers"),
new CommandArgumentPart(true, "input"),
new CommandArgumentPart(false, "answertitle1"),
new CommandArgumentPart(false, "answertitle2 ..."),
new CommandArgumentPart(false, "answertitle2"),
],
[
new SwitchInfo("o", /* Localizable */ "One line choice style", new SwitchOptions()
Expand Down Expand Up @@ -262,7 +262,7 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
ConflictsWith = ["single"],
AcceptsValues = false
})
], true)
], true, true)
], new ChoiceCommand()),

new CommandInfo("chpwd", /* Localizable */ "Changes password for current user",
Expand Down Expand Up @@ -299,8 +299,8 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
[
new CommandArgumentPart(true, "input"),
new CommandArgumentPart(true, "input2"),
new CommandArgumentPart(false, "input3 ..."),
], true)
new CommandArgumentPart(false, "input3"),
], true, true)
], new CombineStrCommand(), CommandFlags.RedirectionSupported | CommandFlags.Wrappable),

new CommandInfo("combine", /* Localizable */ "Combines the two text files or more into the output file.",
Expand All @@ -310,8 +310,8 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
new CommandArgumentPart(true, "output"),
new CommandArgumentPart(true, "input"),
new CommandArgumentPart(true, "input2"),
new CommandArgumentPart(false, "input3 ..."),
})
new CommandArgumentPart(false, "input3"),
}, false, true)
], new CombineCommand()),

new CommandInfo("compare", /* Localizable */ "Compares between the two text files.",
Expand Down Expand Up @@ -1018,15 +1018,15 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
new CommandArgumentInfo(
[
new CommandArgumentPart(true, "Address1"),
new CommandArgumentPart(false, "Address2 ..."),
new CommandArgumentPart(false, "Address2"),
],
[
new SwitchInfo("times", /* Localizable */ "Specifies number of times to ping", new SwitchOptions()
{
ArgumentsRequired = true,
IsNumeric = true
})
])
], false, true)
], new PingCommand()),

new CommandInfo("platform", /* Localizable */ "Gets the current platform",
Expand Down Expand Up @@ -1207,8 +1207,8 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
new CommandArgumentPart(true, "answers"),
new CommandArgumentPart(true, "input"),
new CommandArgumentPart(false, "answertitle1"),
new CommandArgumentPart(false, "answertitle2 ..."),
], true)
new CommandArgumentPart(false, "answertitle2"),
], true, true)
], new SelectCommand()),

new CommandInfo("setsaver", /* Localizable */ "Sets up kernel screensavers",
Expand Down Expand Up @@ -1295,8 +1295,8 @@ internal class UESHShellInfo : BaseShellInfo, IShellInfo
[
new CommandArgumentPart(true, "value"),
new CommandArgumentPart(false, "value2"),
new CommandArgumentPart(false, "value3 ..."),
], true)
new CommandArgumentPart(false, "value3"),
], true, true)
], new SetRangeCommand()),

new CommandInfo("shownotifs", /* Localizable */ "Shows all received notifications",
Expand Down

0 comments on commit 94232c9

Please sign in to comment.