Skip to content

Commit

Permalink
System.CommandLine cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayshinva committed Nov 21, 2020
1 parent d8ff7c7 commit 3838657
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 204 deletions.
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpBase64Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@ public static RootCommand WireUpBase64Commands(this RootCommand rootCommand)
var base64Command = new Command("base64", "Base64");
var base64EncCommand = new Command("encode", "Encode");
base64EncCommand.AddAlias("enc");
base64EncCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
base64EncCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
base64EncCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
base64EncCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
base64EncCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
base64EncCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

base64EncCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
Stream outputStream = null;
Expand Down
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpBase64UrlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@ public static RootCommand WireUpBase64UrlCommands(this RootCommand rootCommand)
var base64UrlCommand = new Command("base64url", "Base64 URL");
var base64UrlEncCommand = new Command("encode", "Encode");
base64UrlEncCommand.AddAlias("enc");
base64UrlEncCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
base64UrlEncCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
base64UrlEncCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
base64UrlEncCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
base64UrlEncCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
base64UrlEncCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

base64UrlEncCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
try
Expand Down
26 changes: 6 additions & 20 deletions Kryptos/Kryptos/WireUpHmacMd5Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,12 @@ public static RootCommand WireUpHmacMd5Commands(this RootCommand rootCommand)
{
var hmacmd5Command = new Command("hmacmd5", "Hash based Message Authentication Code - MD5");
var hmacmd5HashCommand = new Command("hash", "Hash");
hmacmd5HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
hmacmd5HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacmd5HashCommand.AddOption(new Option(new string[] { "--keytext", "-kt" }, "Key Text")
{
Argument = new Argument<string>("text")
});
hmacmd5HashCommand.AddOption(new Option(new string[] { "--keyinput", "-ki" }, "Key file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacmd5HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
hmacmd5HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
hmacmd5HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
hmacmd5HashCommand.AddOption(new Option<string>(new string[] { "--keytext", "-kt" }, "Key Text"));
hmacmd5HashCommand.AddOption(new Option<FileInfo>(new string[] { "--keyinput", "-ki" }, "Key file path"));
hmacmd5HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

hmacmd5HashCommand.Handler = CommandHandler.Create<string, FileInfo, string, FileInfo, FileInfo, IConsole>(async (text, input, keytext, keyinput, output, console) =>
{
Stream outputStream = null;
Expand Down
26 changes: 6 additions & 20 deletions Kryptos/Kryptos/WireUpHmacSha1Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,12 @@ public static RootCommand WireUpHmacSha1Commands(this RootCommand rootCommand)
{
var hmacsha1Command = new Command("hmacsha1", "Hash based Message Authentication Code - SHA1");
var hmacsha1HashCommand = new Command("hash", "Hash");
hmacsha1HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
hmacsha1HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha1HashCommand.AddOption(new Option(new string[] { "--keytext", "-kt" }, "Key Text")
{
Argument = new Argument<string>("text")
});
hmacsha1HashCommand.AddOption(new Option(new string[] { "--keyinput", "-ki" }, "Key file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha1HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
hmacsha1HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
hmacsha1HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
hmacsha1HashCommand.AddOption(new Option<string>(new string[] { "--keytext", "-kt" }, "Key Text"));
hmacsha1HashCommand.AddOption(new Option<FileInfo>(new string[] { "--keyinput", "-ki" }, "Key file path"));
hmacsha1HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

hmacsha1HashCommand.Handler = CommandHandler.Create<string, FileInfo, string, FileInfo, FileInfo, IConsole>(async (text, input, keytext, keyinput, output, console) =>
{
Stream outputStream = null;
Expand Down
26 changes: 6 additions & 20 deletions Kryptos/Kryptos/WireUpHmacSha256Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,12 @@ public static RootCommand WireUpHmacSha256Commands(this RootCommand rootCommand)
{
var hmacsha256Command = new Command("hmacsha256", "Hash based Message Authentication Code - SHA256");
var hmacsha256HashCommand = new Command("hash", "Hash");
hmacsha256HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
hmacsha256HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha256HashCommand.AddOption(new Option(new string[] { "--keytext", "-kt" }, "Key Text")
{
Argument = new Argument<string>("text")
});
hmacsha256HashCommand.AddOption(new Option(new string[] { "--keyinput", "-ki" }, "Key file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha256HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
hmacsha256HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
hmacsha256HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
hmacsha256HashCommand.AddOption(new Option<string>(new string[] { "--keytext", "-kt" }, "Key Text"));
hmacsha256HashCommand.AddOption(new Option<FileInfo>(new string[] { "--keyinput", "-ki" }, "Key file path"));
hmacsha256HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

hmacsha256HashCommand.Handler = CommandHandler.Create<string, FileInfo, string, FileInfo, FileInfo, IConsole>(async (text, input, keytext, keyinput, output, console) =>
{
Stream outputStream = null;
Expand Down
26 changes: 6 additions & 20 deletions Kryptos/Kryptos/WireUpHmacSha384Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,12 @@ public static RootCommand WireUpHmacSha384Commands(this RootCommand rootCommand)
{
var hmacsha384Command = new Command("hmacsha384", "Hash based Message Authentication Code - SHA384");
var hmacsha384HashCommand = new Command("hash", "Hash");
hmacsha384HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
hmacsha384HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha384HashCommand.AddOption(new Option(new string[] { "--keytext", "-kt" }, "Key Text")
{
Argument = new Argument<string>("text")
});
hmacsha384HashCommand.AddOption(new Option(new string[] { "--keyinput", "-ki" }, "Key file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha384HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
hmacsha384HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
hmacsha384HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
hmacsha384HashCommand.AddOption(new Option<string>(new string[] { "--keytext", "-kt" }, "Key Text"));
hmacsha384HashCommand.AddOption(new Option<FileInfo>(new string[] { "--keyinput", "-ki" }, "Key file path"));
hmacsha384HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

hmacsha384HashCommand.Handler = CommandHandler.Create<string, FileInfo, string, FileInfo, FileInfo, IConsole>(async (text, input, keytext, keyinput, output, console) =>
{
Stream outputStream = null;
Expand Down
26 changes: 6 additions & 20 deletions Kryptos/Kryptos/WireUpHmacSha512Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,12 @@ public static RootCommand WireUpHmacSha512Commands(this RootCommand rootCommand)
{
var hmacsha512Command = new Command("hmacsha512", "Hash based Message Authentication Code - SHA512");
var hmacsha512HashCommand = new Command("hash", "Hash");
hmacsha512HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
hmacsha512HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha512HashCommand.AddOption(new Option(new string[] { "--keytext", "-kt" }, "Key Text")
{
Argument = new Argument<string>("text")
});
hmacsha512HashCommand.AddOption(new Option(new string[] { "--keyinput", "-ki" }, "Key file path")
{
Argument = new Argument<FileInfo>("input")
});
hmacsha512HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
hmacsha512HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
hmacsha512HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
hmacsha512HashCommand.AddOption(new Option<string>(new string[] { "--keytext", "-kt" }, "Key Text"));
hmacsha512HashCommand.AddOption(new Option<FileInfo>(new string[] { "--keyinput", "-ki" }, "Key file path"));
hmacsha512HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

hmacsha512HashCommand.Handler = CommandHandler.Create<string, FileInfo, string, FileInfo, FileInfo, IConsole>(async (text, input, keytext, keyinput, output, console) =>
{
Stream outputStream = null;
Expand Down
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpJwtExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@ public static RootCommand WireUpJwtCommands(this RootCommand rootCommand)

var jwtDecCommand = new Command("decode", "Decode");
jwtDecCommand.AddAlias("dec");
jwtDecCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
jwtDecCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
jwtDecCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
jwtDecCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
jwtDecCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
jwtDecCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

jwtDecCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
try
Expand Down
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpMd5Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ public static RootCommand WireUpMd5Commands(this RootCommand rootCommand)
{
var md5Command = new Command("md5", "Message Digest 5");
var md5HashCommand = new Command("hash", "Hash");
md5HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
md5HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
md5HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
md5HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
md5HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
md5HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

md5HashCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
Stream outputStream = null;
Expand Down
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpSha1Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ public static RootCommand WireUpSha1Commands(this RootCommand rootCommand)
{
var sha1Command = new Command("sha1", "Secure Hash Algorithm 1");
var sha1HashCommand = new Command("hash", "Hash");
sha1HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
sha1HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
sha1HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
sha1HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
sha1HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
sha1HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

sha1HashCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
Stream outputStream = null;
Expand Down
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpSha256Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ public static RootCommand WireUpSha256Commands(this RootCommand rootCommand)
{
var sha256Command = new Command("sha256", "Secure Hash Algorithm 2 - 256");
var sha256HashCommand = new Command("hash", "Hash");
sha256HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
sha256HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
sha256HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
sha256HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
sha256HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
sha256HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

sha256HashCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
Stream outputStream = null;
Expand Down
16 changes: 4 additions & 12 deletions Kryptos/Kryptos/WireUpSha384Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ public static RootCommand WireUpSha384Commands(this RootCommand rootCommand)
{
var sha384Command = new Command("sha384", "Secure Hash Algorithm 2 - 384");
var sha384HashCommand = new Command("hash", "Hash");
sha384HashCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")
{
Argument = new Argument<string>("text")
});
sha384HashCommand.AddOption(new Option(new string[] { "--input", "-i" }, "Input file path")
{
Argument = new Argument<FileInfo>("input")
});
sha384HashCommand.AddOption(new Option(new string[] { "--output", "-o" }, "Output file path")
{
Argument = new Argument<FileInfo>("output")
});
sha384HashCommand.AddOption(new Option<string>(new string[] { "--text", "-t" }, "Input Text"));
sha384HashCommand.AddOption(new Option<FileInfo>(new string[] { "--input", "-i" }, "Input file path"));
sha384HashCommand.AddOption(new Option<FileInfo>(new string[] { "--output", "-o" }, "Output file path"));

sha384HashCommand.Handler = CommandHandler.Create<string, FileInfo, FileInfo, IConsole>(async (text, input, output, console) =>
{
Stream outputStream = null;
Expand Down
Loading

0 comments on commit 3838657

Please sign in to comment.