Beispiel #1
0
 private static void SayOptionException(OptionException e)
 {
     SayHeader();
     Write("ModTekInjector.exe: ");
     WriteLine(e.Message);
     WriteLine("Try `ModTekInjector.exe --help' for more information.");
 }
Beispiel #2
0
 private static void SayOptionException(OptionException e)
 {
     SayHeader();
     Write("BattleTechModLoaderInjector.exe: ");
     WriteLine(e.Message);
     WriteLine("Try `BattleTechModLoaderInjector.exe --help' for more information.");
 }
Beispiel #3
0
 private static int SayOptionException(OptionException e)
 {
     SayHeader();
     Write($"{MOD_INJECTOR_EXE_FILE_NAME}: {e.Message}");
     WriteLine($"Try '{MOD_INJECTOR_EXE_FILE_NAME} --help' for more information.");
     return(RC_BAD_OPTIONS);
 }
 private static void SayOptionException(OptionException e)
 {
     SayHeader();
     Write("PhoenixPointModLoaderInjector.exe: ");
     WriteLine(e.Message);
     WriteLine("Try `PhoenixPointModLoaderInjector.exe --help' for more information.");
 }
Beispiel #5
0
 private static void SayOptionException(OptionException e)
 {
     //SayHeader();
     // Write("ModTekInjector.exe: ");
     // Log.M.TWL(0,e.Message);
     // Log.M.TWL(0,"Try `ModTekInjector.exe --help' for more information.");
 }
        public void NewWithInnerException()
        {
            var inner = new ArgumentException();
            var error = new OptionException("Message", inner);

            Assert.Equal("Message", error.Message);
            Assert.True(ReferenceEquals(inner, error.InnerException));
        }
Beispiel #7
0
 /// <summary>
 /// Prints argument parse error information to the console.
 /// </summary>
 /// <param name="options">The option set that generated the error.</param>
 /// <param name="exception">The exception that represents the error.</param>
 private static void ParseError(OptionSet options, OptionException exception)
 {
     lock (SThreeQLConsole.SyncRoot)
     {
         Console.Error.WriteLine("s3ql: ", exception.Message);
         Console.Error.WriteLine();
         options.WriteOptionDescriptions(Console.Error);
     }
 }
 public static void Show(OptionException ex)
 {
     ShowError(new[]
     {
         "",
         "*** ERROR ***",
         "Try --help for more information.",
         "",
         ex.Message
     });
 }
Beispiel #9
0
        private void Usage(OptionException e)
        {
            IndentedTextWriter writer = StdErr;

            if (e != null)
            {
                writer.WriteLine(e.Message);
            }

            writer.WriteLine("Options:");
            Options.WriteOptionDescriptions(writer);
            writer.WriteLine();
        }
Beispiel #10
0
        public void Serialization()
        {
            var formatter = new BinaryFormatter();
            var stream    = new MemoryStream();
            var source    = new OptionException("Message", new ArgumentException("Some error"));

            formatter.Serialize(stream, source);
            var result = Assert.IsType <OptionException>(formatter.Deserialize(new MemoryStream(stream.ToArray())));

            Assert.Equal("Message", result.Message);
            var target = Assert.IsType <ArgumentException>(result.InnerException);

            Assert.Equal("Some error", target.Message);
        }
Beispiel #11
0
        static void NoInput(OptionException oex)
        {
            if (oex == null)
            {
                Console.WriteLine("Warn: No input!");
            }
            else
            {
                Console.Write("xmltidy: ");
                Console.WriteLine(oex.Message);
            }

            Console.WriteLine("Try `xmltidy.exe --help` for more information");
            Environment.Exit(0);
        }
Beispiel #12
0
        /// <summary>
        /// Handles printing exceptions and application exit with
        /// a specified <see cref="IOptions"/> object.
        /// </summary>
        /// <param name="options">The command line options.</param>
        /// <param name="e">The Exception object.</param>
        public static void HandleException(IOptions options, Exception e)
        {
            if (e is OptionException)
            {
                OptionException oe = e as OptionException;
                QuitUsage(options, $"{oe.Message}: {oe.Option}");
            }

            if (e is InitException)
            {
                InitException ie = e as InitException;
                QuitUsage(options, ie.Message);
            }

            HandleException(e);
        }
        /// <summary>
        /// Show the help message
        /// </summary>
        /// <param name="message">the help message</param>
        /// <param name="optionException">the option exception, can be null</param>
        /// <param name="optionSet">the option set object</param>
        private static void ShowHelp(string message, OptionException optionException, OptionSet optionSet)
        {
            if (optionException != null)
            {
                if (!optionException.OptionName.IsNullOrEmpty())
                {
                    Console.Error.Write(optionException.OptionName + ": ");
                }

                Console.Error.WriteLine(optionException.Message);
            }

            Console.Error.WriteLine(message);
            optionSet.WriteOptionDescriptions(Console.Error);
            Environment.Exit(-1);
        }
Beispiel #14
0
        private void Usage(OptionException e)
        {
            IndentedTextWriter writer = StdErr;

            Program.OutputBannerAndCopyright(writer);

            if (e != null)
            {
                writer.WriteLine(e.Message);
            }

            writer.WriteLine($"Usage: { ProgramName } [OPTIONS]* scoringDatabase.db:");
            writer.Indent++;
            writer.WriteLine("Equalize the number of Averaging Matches of all teams in the FTC scoring database by");
            writer.WriteLine("adding never-to-be-played Equalization Matches as necessary to achieve for each the team");
            writer.WriteLine("an averaging match count that is at least the indicated averaging match count goal.");
            writer.WriteLine();
            writer.WriteLine("If the -s option is used, then these added Equalization Matches are scored automatically.");
            writer.WriteLine("Otherwise, after importing the updated database into the FTC Score Keeper, these added ");
            writer.WriteLine("matches need to be manually scored as Wins for Blue.");
            writer.WriteLine();
            writer.WriteLine("In no case are any matches ever *removed*.");
            writer.WriteLine();
            writer.Indent--;
            writer.WriteLine("Options:");
            Options.WriteOptionDescriptions(writer);
            writer.WriteLine();
            writer.Indent++;
            writer.WriteLine("If both -m and -c are used, the averaging match count goal will be the maximum current ");
            writer.WriteLine("averaging match count of any existing team, but capped by the value provided with -c.");
            writer.WriteLine();
            writer.WriteLine("If -m is used without -c, the behavior is as if both -m and -c 10 were used.");
            writer.WriteLine();
            writer.WriteLine("If -c is used without -m, the averaging match count goal is the value provided.");
            writer.Indent--;
            if (e == null)
            {
                Program.ExitApp();
            }
            else
            {
                Program.FailFast();
            }
        }
        public static void TestOptionException()
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
            OptionException oe = new OptionException();

            Assert.That(oe.Message, Is.EqualTo("Exception of type 'NDesk.Options.OptionException' was thrown."));
            Assert.That(oe.OptionName, Is.Null);
            Assert.That(oe.InnerException, Is.Null);

            oe = new OptionException("My Message");

            Assert.That(oe.Message, Is.EqualTo("My Message"));
            Assert.That(oe.OptionName, Is.Null);
            Assert.That(oe.InnerException, Is.Null);

            oe = new OptionException("My Message", oe);

            Assert.That(oe.Message, Is.EqualTo("My Message"));
            Assert.That(oe.OptionName, Is.Null);
            Assert.That(oe.InnerException, Is.Not.Null);
        }
Beispiel #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected abstract void HandleOptionException(OptionException e);
Beispiel #17
0
 public void New()
 {
     _ = new OptionException();
 }
Beispiel #18
0
        public void NewWithMessage()
        {
            var error = new OptionException("Message context");

            Assert.Equal("Message context", error.Message);
        }
Beispiel #19
0
 private static void ErrorWithOptions(OptionException oe)
 {
     Console.WriteLine("Error: " + oe.Message);
     Console.WriteLine("Try 'block --help' for more information");
 }
Beispiel #20
0
 static void ShowExceptionMessage(OptionException optionException)
 {
     Console.Error.Write("{0}: ", System.Reflection.Assembly.GetEntryAssembly().GetName().Name);
     Console.Error.WriteLine(optionException.Message);
     Console.Error.WriteLine("Try `{0} --help' for more information.", System.Reflection.Assembly.GetEntryAssembly().GetName().Name);
 }
Beispiel #21
0
 protected override void HandleOptionException(OptionException e)
 {
     this.ThrownOptionException = e;
 }
Beispiel #22
0
 protected override void HandleOptionException(OptionException e)
 {
     Console.Write("An error occurred while reading input: ");
     Console.WriteLine(e.Message);
     Console.WriteLine("Try using option `--help' for more information.");
 }
Beispiel #23
0
 internal SimpleTaskOptionException(SimpleTask task, OptionException innerException)
     : base($"Task: \"{task.Name}\": {innerException.Message}", innerException)
 {
     this.Task = task;
 }