A project that makes it easier to add command line arguments to applications.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.nuget
Docs/Images
NuGet
Rhyous.SimpleArgs.Example.NetCore
Rhyous.SimpleArgs.Example.Shared
Rhyous.SimpleArgs.Example
Rhyous.SimpleArgs.Net40Client
Rhyous.SimpleArgs.NetStandard1.6
Rhyous.SimpleArgs.NetStandard2.0
Rhyous.SimpleArgs.Shared
Rhyous.SimpleArgs.Tests
.gitignore
Fork and Contribute License.txt
README.md
ReleaseNotes.txt
Rhyous.SimpleArgs.sln

README.md

SimpleArgs

A project that makes it easier to add command line arguments to applications.

Steps to use SimpleArgs

  1. Install the NuGet package. It adds the SimpleArgs dll and an ArgsHandler.cs file.

    install-package Rhyous.SimpleArgs
    // Or if you don't want a separate dll, install this:
    install-package Rhyous.SimpleArgs.Sources
    
  2. Add your new Arguments to the InitializeArguments override of the ArgsHandler.cs file.

    public override void InitializeArguments()
    {
        Arguments.AddRange(new List<Argument>
        {
            new Argument
            {
                Name = "Echo",
                ShortName = "E",
                Description = "I echo to the console whater you put after Echo=",
                Example = "Echo=\"Hello, World!\"",
                Action = (value) => { Console.WriteLine(value);}
            },
            // Add more args here
        });
    }
    
  3. In Program.cs add this line of code to Main()

    static void Main(string[] args)
    {
        new ArgsManager<ArgsHandler>().Start(args);
    }
    
  4. In the ArgsHandler.cs file, your new take action point is in the HandleArgs() method.

    public void HandleArgs(IReadArgs inArgsHandler)
    {
        base.HandleArgs(inArgsHandler);
        Console.WriteLine("I handled the args!!!");
        // This is where you start your work now
    }
    
  5. If you run with no args, you will be given usage.

    Usage:
      SimpleArgs.Example.exe Echo="Hello, World!"
      
    Arguments:
      Echo   (Optional) I echo to the console whater you put after Echo=
    
    Press any key to continue . . .
    
  6. Access your arguments statically anywhere using static class Args.

    Args.Value("Echo") // returns value
    Args.Get("Echo") // Returns Argument object