Esempio n. 1
0
        static int Main(string[] args)
        {
            try {
                Program p = new Program();

                var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
                return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out));
            } catch (ReflectionTypeLoadException ex) {
                StringBuilder sb = new StringBuilder();
                foreach (Exception exSub in ex.LoaderExceptions)
                {
                    sb.AppendLine(exSub.Message);
                    if (exSub is FileNotFoundException)
                    {
                        FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                        if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                        {
                            sb.AppendLine("Fusion Log:");
                            sb.AppendLine(exFileNotFound.FusionLog);
                        }
                    }
                    sb.AppendLine();
                }
                string errorMessage = sb.ToString();
                Console.WriteLine(errorMessage);
                //Display or log the error based on your application.
                return(0);
            }
        }
Esempio n. 2
0
        /// <summary>Runs the application.</summary>
        /// <param name="args">The arguments.</param>
        /// <returns>Result code.</returns>
        public int Run(string[] args)
        {
            try
            {
                WriteAppInfo();

                LibZContainer.RegisterEncoder("deflate", DefaultCodecs.DeflateEncoder, true);
                LibZContainer.RegisterCodec("zlib", DefaultCodecs.ZLibEncoder, DefaultCodecs.ZLibDecoder);

                ConfigureLogging();
                LoadPlugins();
                RegisterPlugins();

                try
                {
                    Log.Trace("LibZ started");
                    var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(GetType());
                    return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out));
                }
                finally
                {
                    Log.Trace("LibZ stopped");
                }
            }
            catch (Exception e)
            {
                Log.Error("{0}: {1}", e.GetType().Name, e.Message);
                Log.Debug(e.StackTrace);
                return(1);
            }
        }
 static int Main(string[] args)
 {
     try
     {
         var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
         foreach (var c in commands)
         {
             c.SkipsCommandSummaryBeforeRunning();
         }
         args = SupportCompatibilityMode(args, commands);
         return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out));
     }
     catch (Exception exc)
     {
         Console.Error.WriteLine(exc);
         return(1);
     }
     finally
     {
         if (!Console.IsOutputRedirected && OwnsConsole())
         {
             Console.WriteLine("Press any key to exit ...");
             Console.ReadKey();
         }
     }
 }
Esempio n. 4
0
 static int Main(string[] args)
 {
     return(ConsoleCommandDispatcher.DispatchCommand(
                ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)),
                args,
                Console.Out));
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(App));

            ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
        }
Esempio n. 6
0
        internal static int Main(string[] args)
        {
            Console.Write(GetHeader());

            int rc = 42; // generic failure

            try
            {
                // locate any commands in the assembly (or use an IoC container, or whatever source)
                var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));

                // then run them.
                rc = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
                if (rc == 0)
                {
                    ConsoleColor save = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Succeeded.");
                    Console.ForegroundColor = save;
                }
            }
            catch (Exception e)
            {
                e.Dump(Console.Out);
                rc = 99;
            }

            return(rc);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            int result;

            try
            {
                var commandToExecute = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
                result = ConsoleCommandDispatcher.DispatchCommand(commandToExecute, args, Console.Out);
            }
            catch (Exception e)
            {
                result = -1;
                Console.Error.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                    Console.Error.WriteLine(e.InnerException.Message);
                }
            }

            if (Debugger.IsAttached)
            {
                Debugger.Break();
            }
            Environment.Exit(result);
        }
        public void AbstractCommandArentLoaded()
        {
            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(this.GetType());

            Assert.IsTrue(commands.Any(c => c.GetType() == typeof(NonabstractCommand)), "No non-abstract commands are found.");
            Assert.IsFalse(commands.Any(c => c.GetType() == typeof(AbstractCommand)), "AbstractCommands present - should be ignored.");
            Assert.IsFalse(commands.Any(c => c.GetType() == typeof(AnotherAbstractCommand)), "AnotherAbstractCommand present - should be ignored.");
        }
Esempio n. 9
0
        private static int Main(string[] args)
        {
            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));

            var result = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);

            return(result);
        }
Esempio n. 10
0
        static int Main(string[] args)
        {
            Log.Instance.LineAdded += (s, e) => Console.WriteLine(e.Line);
            Console.WriteLine("UI5Uploader - Upload Open/SAPUI5 applications to a SAP ABAP repository");
            Console.WriteLine("Copyright (c) 2015 Bernhard Klefer, BTC AG. Read license file for details.");

            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));

            return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out));
        }
Esempio n. 11
0
        static int Main(string[] args)
        {
            Console.Title = "YOLOv4";
            GradientEngine.UseEnvironmentFromVariable();
            TensorFlowSetup.Instance.EnsureInitialized();

            return(ConsoleCommandDispatcher.DispatchCommand(
                       ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)),
                       args, Console.Out));
        }
        static int Main(string[] args)
        {
            GradientSetup.OptInToUsageDataCollection();
            // force Gradient initialization
            tensorflow.tf.no_op();

            return(ConsoleCommandDispatcher.DispatchCommand(
                       ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Gpt2Program)),
                       args, Console.Out));
        }
Esempio n. 13
0
 public static void Main(string[] args)
 {
     // Process Operation
     try {
         var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(MainClass));
         ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
     } catch (Exception e) {
         Console.WriteLine("Unable to process command...");
     }
 }
        public override void Specify()
        {
            it("when loading commands from an assembly, abstract commands are ignored", delegate
            {
                var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(this.GetType());

                expect(() => commands.Any(c => c.GetType() == typeof(NonabstractCommand)));
                expect(() => !commands.Any(c => c.GetType() == typeof(AbstractCommand)));
                expect(() => !commands.Any(c => c.GetType() == typeof(AnotherAbstractCommand)));
            });
        }
Esempio n. 15
0
        static int Main(string[] args)
        {
            GradientLog.OutputWriter = Console.Out;

            tf.no_op();

            np = PythonEngine.ImportModule("numpy");
            return(ConsoleCommandDispatcher.DispatchCommand(
                       ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(LinearSvmProgram)),
                       args, Console.Out));
        }
Esempio n. 16
0
        public static int Main(String[] args)
        {
            IEnumerable <ConsoleCommand> commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
            int result = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
            return(result);
        }
Esempio n. 17
0
 public static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         Console.WriteLine("UI is unimplemented. Try 'help' for usage.");
     }
     else
     {
         ConsoleCommandDispatcher.DispatchCommand(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)),
                                                  args, Console.Out);
     }
 }
Esempio n. 18
0
        static int Main(string[] args)
        {
            Console.Title            = "LinearSVM";
            GradientLog.OutputWriter = Console.Out;
            GradientEngine.UseEnvironmentFromVariable();

            // required before using PythonEngine
            TensorFlowSetup.Instance.EnsureInitialized();
            return(ConsoleCommandDispatcher.DispatchCommand(
                       ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(LinearSvmProgram)),
                       args, Console.Out));
        }
Esempio n. 19
0
        static int Main(string[] args)
        {
            GradientLog.OutputWriter = Console.Out;
            GradientSetup.UseEnvironmentFromVariable();

            // required before using PythonEngine
            GradientSetup.EnsureInitialized();
            np = PythonEngine.ImportModule("numpy");
            return(ConsoleCommandDispatcher.DispatchCommand(
                       ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(LinearSvmProgram)),
                       args, Console.Out));
        }
Esempio n. 20
0
        public static int Main(string[] args)
        {
            GradientSetup.OptInToUsageDataCollection();
            GradientSetup.UseEnvironmentFromVariable();

            dynamic config = config_pb2.ConfigProto();

            config.gpu_options.allow_growth = true;
            tf.keras.backend.set_session(Session.NewDyn(config: config));

            return(ConsoleCommandDispatcher.DispatchCommand(
                       ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(CSharpOrNotProgram)),
                       args, Console.Out));
        }
Esempio n. 21
0
        static int Main(string[] args)
        {
            Repository.PerformMigration();

            //Register for event
            EventBus.OnMessageFired += EventBus_OnMessageFired;

            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
            var result   = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);

#if DEBUG
            WitForExit();
#endif
            return(result);
        }
        private static void Main(string[] args)
        {
            if (args.Any())
            {
                var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
                ConsoleCommandDispatcher.DispatchCommand(commands, args, new Log4NetTextWriter());
            }
            else
            {
                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.ApplicationExit += Dispose;
                System.Windows.Forms.Application.ThreadException += OnThreadException;

                AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

                System.Windows.Forms.Application.Run(V);
            }
        }
Esempio n. 23
0
        public static int Main(string[] args)
        {
            var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (Directory.GetCurrentDirectory() != location)
            {
                Log.Information($"Change folder from '{Directory.GetCurrentDirectory()}' to '{location}'.");
                Directory.SetCurrentDirectory(location ?? ".");
            }

            Log.Logger = LogSetup.Default().CreateLogger();
            Log.Information($"Starting Command.Bot app.");
            // locate any commands in the assembly (or use an IoC container, or whatever source)
            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(BotCommand));

            // then run them.
            return(ConsoleCommandDispatcher.DispatchCommand(commands, args, System.Console.Out));
        }
Esempio n. 24
0
        public static int Main(string[] args)
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                Converters = new List <JsonConverter> {
                    new StringEnumConverter()
                }
            };

            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
            var result   = ConsoleCommandDispatcher.DispatchCommand(commands, args, System.Console.Out);

            System.Console.WriteLine("Press any key to continue...");
            System.Console.ReadLine();

            return(result);
        }
Esempio n. 25
0
        static int Main(string[] args)
        {
            var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));

            if (args.Length == 0)
            {
                Console.Write("Command to execute: ");
                string subcommand = Console.ReadLine();
                args = new string[] { subcommand };
            }

            int result = ConsoleCommandDispatcher.DispatchCommand(
                commands: commands,
                arguments: args,
                consoleOut: Console.Out,
                skipExeInExpectedUsage: true
                );

            return(result);
        }
Esempio n. 26
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 private static int Main(string[] args)
 {
     try
     {
         var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
         if (Directory.GetCurrentDirectory() != location)
         {
             Log.Information($"Change folder from '{Directory.GetCurrentDirectory()}' to '{location}'.");
             Directory.SetCurrentDirectory(location ?? ".");
         }
         Log.Logger = LogSetup.Default().CreateLogger();
         Log.Information("Starting Command.Bot service.");
         // locate any commands in the assembly (or use an IoC container, or whatever source)
         var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(ServiceCommand));
         // then run them.
         return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out));
     }
     catch (Exception e)
     {
         Log.Error($"Failed to launch service:{e.Message}", e);
         throw;
     }
 }
Esempio n. 27
0
 private static IEnumerable <ConsoleCommand> GetCommands()
 {
     return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)));
 }
Esempio n. 28
0
 public static IEnumerable <ConsoleCommand> GetCommands() => ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
Esempio n. 29
0
        private static int Main(string[] args)
        {
            var items = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));

            return(ConsoleCommandDispatcher.DispatchCommand(items, args, System.Console.Out));
        }
Esempio n. 30
0
 private static IEnumerable <ConsoleCommand> GetCommands(Type start)
 {
     return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(start));
 }