Exemple #1
0
 private void ProcessCommandLineOptions(Action <string, BaseUtils.CommandArgs, bool> getopt)       // go thru command line..
 {
     string[] cmdlineopts     = Environment.GetCommandLineArgs().ToArray();
     BaseUtils.CommandArgs ca = new BaseUtils.CommandArgs(cmdlineopts, 1);
     //System.Diagnostics.Debug.WriteLine("Command Line:");
     while (ca.More)
     {
         getopt(ca.Next().ToLowerInvariant(), ca, false);
     }
 }
Exemple #2
0
 private void ProcessOptionFile(string filepath, Action <string, BaseUtils.CommandArgs, bool> getopt)       // read file and process options
 {
     //System.Diagnostics.Debug.WriteLine("Read File " + filepath);
     foreach (string line in File.ReadAllLines(filepath))
     {
         if (!line.IsEmpty())
         {
             //string[] cmds = line.Split(new char[] { ' ' }, 2).Select(s => s.Trim()).ToArray();    // old version..
             string[] cmds            = BaseUtils.StringParser.ParseWordList(line, separ: ' ').ToArray();
             BaseUtils.CommandArgs ca = new BaseUtils.CommandArgs(cmds);
             getopt("-" + ca.Next().ToLowerInvariant(), ca, true);
         }
     }
 }
Exemple #3
0
        private void ProcessOption(string optname, BaseUtils.CommandArgs ca, bool toeol)
        {
            optname = optname.ToLowerInvariant();
            //System.Diagnostics.Debug.WriteLine("     Option " + optname);

            if (optname == "-optionsfile" || optname == "-appfolder")
            {
                ca.Remove();   // waste it
            }
            else if (optname == "-translationfolder")
            {
                translationfolder = ca.NextEmpty();
                TranslatorDirectoryIncludeSearchUpDepth = ca.Int();
            }
            else if (optname == "-userdbpath")
            {
                UserDatabasePath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-cmdr" || optname == "-commander")
            {
                Commander = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-profile")
            {
                Profile = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-systemsdbpath")
            {
                SystemDatabasePath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-iconspath")
            {
                IconsPath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-notificationfolder")
            {
                NotificationFolderOverride = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-tracelog")
            {
                TraceLog = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-fontsize")
            {
                FontSize = (toeol ? ca.Rest() : ca.NextEmpty()).InvariantParseFloat(0);
            }
            else if (optname == "-font")
            {
                Font = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-language")
            {
                SelectLanguage = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname.StartsWith("-"))
            {
                string opt = optname.Substring(1);

                switch (opt)
                {
                case "safemode": SafeMode = true; break;

                case "norepositionwindow": NoWindowReposition = true; break;

                case "portable": StoreDataInProgramDirectory = true; break;

                case "nrw": NoWindowReposition = true; break;

                case "showactionbutton": ActionButton = true; break;

                case "noload": NoLoad = true; break;

                case "nosystems": NoSystemsLoad = true; break;

                case "logexceptions": LogExceptions = true; break;

                case "nogithubpacks": DontAskGithubForPacks = true; break;

                case "checkrelease": CheckRelease = true; break;

                case "checkgithub": CheckGithubFiles = true; break;

                case "nocheckrelease": CheckRelease = false; break;

                case "nocheckgithub": CheckGithubFiles = false; break;

                case "disablemerge": DisableMerge = true; break;

                case "edsmbeta":
                    EDSMClass.ServerAddress = "http://beta.edsm.net:8080/";
                    break;

                case "edsmnull":
                    EDSMClass.ServerAddress = "";
                    break;

                case "disablebetacheck":
                    DisableBetaCommanderCheck = true;
                    break;

                case "forcebeta":           // use to move logs to a beta commander for testing
                    ForceBetaOnCommander = true;
                    break;

                case "notheme": NoTheme = true; break;

                case "notabs": NoTabs = true; break;

                case "tabsreset": TabsReset = true; break;

                case "nosound": NoSound = true; break;

                case "no3dmap": No3DMap = true; break;

                case "notitleinfo": DisableShowDebugInfoInTitle = true; break;

                case "resetlanguage": ResetLanguage = true; break;

                default:
                    System.Diagnostics.Debug.WriteLine($"Unrecognized option -{opt}");
                    break;
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"Unrecognized non option {optname}");
            }
        }
Exemple #4
0
        private void ProcessOption(string optname, BaseUtils.CommandArgs ca)
        {
            optname = optname.ToLowerInvariant();
            //System.Diagnostics.Debug.WriteLine("     Option " + optname);

            if (optname == "-optionsfile" || optname == "-appfolder")
            {
                ca.Remove();   // waste it
            }
            else if (optname == "-appfolder")
            {
                if (AppDataDirectory == null) // Only override AppFolder if AppDataDirectory has not been set
                {
                    AppFolder = ca.NextEmpty;
                }
            }
            else if (optname == "-translationfolder")
            {
                translationfolder = ca.NextEmpty;
                TranslatorDirectoryIncludeSearchUpDepth = ca.Int;
            }
            else if (optname == "-userdbpath")
            {
                UserDatabasePath = ca.NextEmpty;
            }
            else if (optname == "-systemsdbpath")
            {
                SystemDatabasePath = ca.NextEmpty;
            }
            else if (optname == "-iconspath")
            {
                IconsPath = ca.NextEmpty;
            }
            else if (optname == "-tracelog")
            {
                TraceLog = ca.NextEmpty;
            }
            else if (optname.StartsWith("-"))
            {
                string opt = optname.Substring(1);

                switch (opt)
                {
                case "norepositionwindow": NoWindowReposition = true; break;

                case "portable": StoreDataInProgramDirectory = true; break;

                case "nrw": NoWindowReposition = true; break;

                case "showactionbutton": ActionButton = true; break;

                case "noload": NoLoad = true; break;

                case "nosystems": NoSystemsLoad = true; break;

                case "logexceptions": LogExceptions = true; break;

                case "nogithubpacks": DontAskGithubForPacks = true; break;

                case "checkrelease": CheckReleaseInDebug = true; break;

                case "edsmbeta":
                    EDSMClass.ServerAddress = "http://beta.edsm.net:8080/";
                    break;

                case "edsmnull":
                    EDSMClass.ServerAddress = "";
                    break;

                case "disablebetacheck":
                    DisableBetaCommanderCheck = true;
                    break;

                case "forcebeta":           // use to move logs to a beta commander for testing
                    ForceBetaOnCommander = true;
                    break;

                case "notheme": NoTheme = true; break;

                case "tabsreset": TabsReset = true; break;

                case "nosound": NoSound = true; break;

                case "no3dmap": No3DMap = true; break;

                case "notitleinfo": DisableShowDebugInfoInTitle = true; break;

                case "resetlanguage": ResetLanguage = true; break;

                default:
                    System.Diagnostics.Debug.WriteLine($"Unrecognized option -{opt}");
                    break;
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"Unrecognized non option -{optname}");
            }
        }
        // standard process option (excepting -optionsfile and -appfolder)
        private void ProcessOption(string optname, BaseUtils.CommandArgs ca, bool toeol)
        {
            optname = optname.ToLowerInvariant();
            //System.Diagnostics.Debug.WriteLine("     Option " + optname);

            if (optname == "-optionsfile" || optname == "-appfolder") // not processed thru this function
            {
                ca.Remove();                                          // waste it
            }
            else if (optname == "-translationfolder")
            {
                translationfolder = ca.NextEmpty();
                TranslatorDirectoryIncludeSearchUpDepth = ca.Int();
            }
            else if (optname == "-userdbpath")
            {
                UserDatabasePath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-cmdr" || optname == "-commander")
            {
                Commander = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-profile")
            {
                Profile = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-systemsdbpath")
            {
                SystemDatabasePath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-iconspath")
            {
                IconsPath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-notificationfolder")
            {
                NotificationFolderOverride = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-tracelog")
            {
                TraceLog = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-fontsize")
            {
                FontSize = (toeol ? ca.Rest() : ca.NextEmpty()).InvariantParseFloat(0);
            }
            else if (optname == "-font")
            {
                Font = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-language")
            {
                SelectLanguage = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-webserverfolder" || optname == "-wsf")
            {
                WebServerFolder = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-outputeventhelp")
            {
                OutputEventHelp = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-defaultjournalfolder")
            {
                DefaultJournalFolder = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-journalfilematch")
            {
                DefaultJournalMatchFilename = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-minjournaldateutc")
            {
                string s = toeol ? ca.Rest() : ca.NextEmpty();
                MinJournalDateUTC = s.ParseDateTime(DateTime.MinValue, System.Globalization.CultureInfo.CurrentCulture);
            }
            else if (optname == "-historyloaddaylimit")
            {
                string s = (toeol ? ca.Rest() : ca.NextEmpty());
                if (DateTime.TryParse(s, out DateTime t))
                {
                    var delta = DateTime.UtcNow - t;
                    HistoryLoadDayLimit = (int)((delta.TotalHours + 23.999) / 24);
                }
                else
                {
                    HistoryLoadDayLimit = s.InvariantParseInt(0);
                }
            }
            else if (optname.StartsWith("-"))
            {
                string opt = optname.Substring(1);

                switch (opt)
                {
                case "safemode": SafeMode = true; break;

                case "norepositionwindow": NoWindowReposition = true; break;

                case "minimize":
                case "minimise": MinimiseOnOpen = true; break;

                case "maximise":
                case "maximize": MaximiseOnOpen = true; break;

                case "portable": StoreDataInProgramDirectory = true; break;

                case "nrw": NoWindowReposition = true; break;

                case "showactionbutton": ActionButton = true; break;

                case "noload": NoLoad = true; break;

                case "nosystems": NoSystemsLoad = true; break;

                case "logexceptions": LogExceptions = true; break;

                case "nogithubpacks": DontAskGithubForPacks = true; break;

                case "checkrelease": CheckRelease = true; break;

                case "checkgithub": CheckGithubFiles = true; break;

                case "nocheckrelease": CheckRelease = false; break;

                case "nocheckgithub": CheckGithubFiles = false; break;

                case "disablemerge": DisableMerge = true; break;

                case "edsmbeta":
                    EDSMClass.ServerAddress = "http://beta.edsm.net:8080/";
                    break;

                case "edsmnull":
                    EDSMClass.ServerAddress = "";
                    break;

                case "disablebetacheck":
                    DisableBetaCommanderCheck = true;
                    break;

                case "forcebeta":           // use to move logs to a beta commander for testing
                    ForceBetaOnCommander = true;
                    break;

                case "notheme": NoTheme = true; break;

                case "notabs": NoTabs = true; break;

                case "tabsreset": TabsReset = true; break;

                case "nosound": NoSound = true; break;

                case "no3dmap": No3DMap = true; break;

                case "notitleinfo": DisableShowDebugInfoInTitle = true; break;

                case "resetlanguage": ResetLanguage = true; break;

                case "tempdirindatadir": TempDirInDataDir = true; break;

                case "notempdirindatadir": TempDirInDataDir = false; break;

                case "lowpriority": ProcessPriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal; break;

                case "backgroundpriority": ProcessPriorityClass = System.Diagnostics.ProcessPriorityClass.Idle; break;

                case "highpriority": ProcessPriorityClass = System.Diagnostics.ProcessPriorityClass.High; break;

                case "abovenormalpriority": ProcessPriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal; break;

                case "realtimepriority": ProcessPriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime; break;

                case "forcetls12": ForceTLS12 = true; break;

                case "disabletimedisplay": DisableTimeDisplay = true; break;

                case "disablecommanderselect": DisableCommanderSelect = true; break;

                case "disableversiondisplay": DisableVersionDisplay = true; break;

                case "enabletgrightclicks": EnableTGRightDebugClicks = true; break;

                default:
                    System.Diagnostics.Debug.WriteLine($"Unrecognized option -{opt}");
                    break;
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"Unrecognized non option {optname}");
            }
        }
Exemple #6
0
        private void ProcessOption(string optname, BaseUtils.CommandArgs ca, bool toeol)
        {
            optname = optname.ToLowerInvariant();
            //System.Diagnostics.Debug.WriteLine("     Option " + optname);

            if (optname == "-optionsfile" || optname == "-appfolder")
            {
                ca.Remove();   // waste it
            }
            else if (optname == "-translationfolder")
            {
                translationfolder = ca.NextEmpty();
                TranslatorDirectoryIncludeSearchUpDepth = ca.Int();
            }
            else if (optname == "-userdbpath")
            {
                UserDatabasePath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-cmdr" || optname == "-commander")
            {
                Commander = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-systemsdbpath")
            {
                SystemDatabasePath = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-tracelog")
            {
                TraceLog = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-fontsize")
            {
                FontSize = (toeol ? ca.Rest() : ca.NextEmpty()).InvariantParseFloat(0);
            }
            else if (optname == "-font")
            {
                Font = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-language")
            {
                SelectLanguage = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname == "-outputeventhelp")
            {
                OutputEventHelp = toeol ? ca.Rest() : ca.NextEmpty();
            }
            else if (optname.StartsWith("-"))
            {
                string opt = optname.Substring(1);

                switch (opt)
                {
                case "norepositionwindow": NoWindowReposition = true; break;

                case "nrw": NoWindowReposition = true; break;

                case "safemode": SafeMode = true; break;

                case "portable": StoreDataInProgramDirectory = true; break;

                case "logexceptions": LogExceptions = true; break;

                case "checkrelease": CheckRelease = true; break;

                case "nocheckrelease": CheckRelease = false; break;

                case "disablemerge": DisableMerge = true; break;

                case "edsmbeta":
                    EDSMClass.ServerAddress = "http://beta.edsm.net:8080/";
                    break;

                case "edsmnull":
                    EDSMClass.ServerAddress = "";
                    break;

                case "disablebetacheck":
                    DisableBetaCommanderCheck = true;
                    break;

                case "forcebeta":           // use to move logs to a beta commander for testing
                    ForceBetaOnCommander = true;
                    break;

                case "resetlanguage": ResetLanguage = true; break;

                case "tempdirindatadir": TempDirInDataDir = true; break;

                case "notempdirindatadir": TempDirInDataDir = false; break;

                case "lowpriority": LowPriority = true; break;

                case "nolowpriority": LowPriority = false; break;

                case "backgroundpriority": BackgroundPriority = true; break;

                case "nobackgroundpriority": BackgroundPriority = false; break;

                case "forcetls12": ForceTLS12 = true; break;

                case "disabletimedisplay": DisableTimeDisplay = true; break;

                default:
                    System.Diagnostics.Debug.WriteLine($"Unrecognized option -{opt}");
                    break;
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"Unrecognized non option {optname}");
            }
        }