class Program
{
    static void Main(string[] args)
    {            
        // stash the color state
        ConsoleColorState state = RC.ColorState;

        // create the argument parser
        ArgumentParser parser = new ArgumentParser("ArgumentExample", "Example of argument parsing");

        // create the argument for a string
        StringArgument StringArg = new StringArgument("String", "Example string argument", "This argument demonstrates string arguments");

        // add the argument to the parser 
        parser.Add("/", "String", StringArg);

        try
        {       
            // parse arguemnts
            parser.Parse(args);

            // did the parser detect a /? arguemnt 
            if (parser.HelpMode == false) 
            {
                // was the string argument defiend 
                if (StringArg.Defined == true)
                {
                    // write its value
                    RC.WriteLine(ConsoleThemeColor.TitleText, "String argument was defined");
                    CmdHelper.WriteInfoToConsole("String Value", StringArg.Value, RC.Theme[ConsoleThemeColor.TextGood], true);
                }
                else
                {
                    // was not defiend 
                    RC.WriteLine(ConsoleThemeColor.TitleText, "String argument was not defined");
                }
            }                
        }
        catch (Exception ex)
        {
            // Write the exception to the console 
            RC.WriteException(0001, ex);
        }
        finally
        {
            RC.PromptForKey("Press any key to exit..", true, false);

            // Reset the color state
            RC.ColorState = state;
        }
    }
}

Last edited Jun 24, 2011 at 1:39 AM by RugCode, version 7

Comments

No comments yet.