DigitalZenWorks.CommandLine.Commands
1.3.10
dotnet add package DigitalZenWorks.CommandLine.Commands --version 1.3.10
NuGet\Install-Package DigitalZenWorks.CommandLine.Commands -Version 1.3.10
<PackageReference Include="DigitalZenWorks.CommandLine.Commands" Version="1.3.10" />
paket add DigitalZenWorks.CommandLine.Commands --version 1.3.10
#r "nuget: DigitalZenWorks.CommandLine.Commands, 1.3.10"
// Install DigitalZenWorks.CommandLine.Commands as a Cake Addin #addin nuget:?package=DigitalZenWorks.CommandLine.Commands&version=1.3.10 // Install DigitalZenWorks.CommandLine.Commands as a Cake Tool #tool nuget:?package=DigitalZenWorks.CommandLine.Commands&version=1.3.10
DigitalZenWorks.CommandLine.Commands
This C# client library that provides light weight functionality to help process command line options.
Please ⭐ star this project!
Getting Started
Installation
Git
git clone https://github.com/jamesjohnmcguire/CommandLineCommands
Nuget
PM> Install-Package DigitalZenWorks.CommandLine.Commands
Usage:
Library and API usage:
Usage is intended to be simple and direct - Process command line arguments and get going with your business.
NEW!
Define a list of valid commands in JSON file, then load the file into the library. Here is an example of the JSON command definitions file:
[
{
"command": "help",
"description": "Show this information"
},
{
"command": "dbx-to-pst",
"description": "Migrate dbx files to pst file",
"options":
[
{
"shortName": "e",
"longName": "encoding",
"requiresParameter": true
}
],
"parameters":
[
"dbx files path",
"PST file path"
]
},
{
"command": "eml-to-pst",
"description": "Migrate eml files to pst file",
"options":
[
{
"shortName": "a",
"longName": "adjust",
"requiresParameter": false
}
],
"parameters":
[
"eml files path",
"PST file path"
]
},
{
"command": "list-folders",
"description": "List all sub folders of a given store or folder",
"options":
[
{
"shortName": "r",
"longName": "recurse",
"requiresParameter": false
}
],
"parameters":
[
"PST file path",
"folder path"
]
},
{
"command": "remove-duplicates",
"description": "Remove duplicate messages",
"options":
[
{
"shortName": "n",
"longName": "dryrun",
"requiresParameter": false
},
{
"shortName": "s",
"longName": "flush",
"requiresParameter": false
}
],
"parameters":
[
"PST file path"
]
}
]
Note: This example taken from: https://github.com/jamesjohnmcguire/DigitalZenWorks.Email.ToolKit
Otherwise, to pragmatically create a list of commands that the application will support, here is an example:
IList<Command> commands = new List<Command>();
Command help = new ("help");
help.Description = "Show this information";
commands.Add(help);
CommandOption encoding = new ("e", "encoding", true);
IList<CommandOption> options = new List<CommandOption>();
options.Add(encoding);
Command someCommand = new (
"some-command", options, 1, "A Do Something Command");
commands.Add(someCommand);
The third parameter is the minimum amount of required parameters, such as data file path. The other parameters should be self-explanatory.
Then instantiate a CommandLineInstance object:
CommandLineInstance commandLine = new (commands, arguments);
If all goes well and the supplied arguments pass validation, the active command object will be available, and you can get on your way:
if (commandLine.ValidArguments == true)
{
Command command = commandLine.Command;
switch (command.Name)
{
case "some-command":
DoSomething(command);
break;
}
}
Getting the associated additional parameters and options, can be done as follows:
string dataFilePath = command.Parameters[0];
bool dryRun = command.DoesOptionExist("n", "dryrun");
Contributing
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Process:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Coding style
Please match the current coding style. Most notably:
- One operation per line
- Use complete English words in variable and method names
- Attempt to declare variable and method names in a self-documenting manner
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
James John McGuire - @jamesmc - jamesjohnmcguire@gmail.com
Project Link: https://github.com/jamesjohnmcguire/CommandLineCommands
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
-
.NETStandard 2.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
-
net5.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
-
net6.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
-
net7.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
-
net8.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
-
net9.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- NewtonSoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.