Skip to content

Folleach/ConsoleUtils

Repository files navigation

ConsoleUtils

For help & simplify to your code <3

Install

Add to your csproj

<PackageReference Include="Folleach.ConsoleUtils" Version="1.0.0" />

Or download from NuGet

Examples

Setup console

ExtendedConsole.SetupUTF8(); // For use UTF-8 by default, instead of local culture

Args

var parsedArgs = new Args(args);

For console command programm.exe -a -b with_value --full-name "The name" -xyz 10

Args will be

Key Value
a
b with_value
full-name The name
x
y
z 10

And it can be used as

Console.WriteLine(parsedArgs.Contains("a"));  // true
Console.WriteLine(parsedArgs.GetString("a")); // null

Console.WriteLine(parsedArgs.GetString("full-name")); // The name

if (parsedArgs.TryGetString("b", out var value)) // If contains "b"
    Console.WriteLine(value);                    // write the value

foreach (var (key, value) in parsedArgs)     // Access to all args
    Console.WriteLine($"{key} is {value}");  // and write them

return "Be careful ;)";

About

Utilities for console

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages