Program.cs

src/ArtheaConsole/Program.cs · 2.6 KB

From the archive Arthea-src-1.0.zip

Download the archive   « Back to the archive contents

#region Arthea License

/***********************************************************************
*  Arthea MUD by R. Jennings (2007)      http://arthea.googlecode.com/ *
*  By using this code you comply with the Artistic and GPLv2 Licenses. *
***********************************************************************/

#endregion

using System;
using Arthea;
using Arthea.Commands.Admin;
using Arthea.Environment;

namespace ArtheaConsole
{
    /// <summary>
    /// The starting point
    /// </summary>
    public class Program
    {
        #region [rgn] Methods (1)

        // [rgn] Public Methods (1)

        /// <summary>
        /// the main method
        /// </summary>
        /// <param name="args">The args.</param>
        public static void Main(string[] args)
        {
            Arguments CmdLine = new Arguments(args);

            if (CmdLine["help"] != null || CmdLine["h"] != null)
            {
                Console.WriteLine("--help, -h     : this help");
                Console.WriteLine("--version, -v  : show version information");
                Console.WriteLine("--port <port>  : set incomming port number");
                Console.WriteLine("--rport <port> : set reboot recovery port");
            }

            if (CmdLine["version"] != null || CmdLine["v"] != null)
            {
                Console.Write(Server.Instance.Version);
                Console.WriteLine(" (Console v{0}.{1}", Environment.Version.Major,
                                  Environment.Version.Minor);
                Console.WriteLine(Server.Instance.About);
                Console.ReadLine();
                return;
            }

            if (CmdLine["rport"] != null)
            {
                short rport;

                if (short.TryParse(CmdLine["rport"], out rport))
                {
                    RebootRecovery.Port = rport;
                }
                else
                {
                    Console.WriteLine("Invalid reboot recovery port number.");
                    return;
                }
            }

            if (CmdLine["port"] != null)
            {
                short port;

                if (short.TryParse(CmdLine["port"], out port))
                {
                    Globals.PortNumber = port;
                }
                else
                {
                    Console.WriteLine("Invalid port number.");
                    return;
                }
            }

            Server.Instance.Start(CmdLine["reboot"] != null);

            Server.Instance.Shutdown();
        }

        #endregion [rgn]
    }
}

Site Stats

Snippets: 1791
Codebases: 571