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); } }
/// <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(); } } }
static int Main(string[] args) { return(ConsoleCommandDispatcher.DispatchCommand( ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)), args, Console.Out)); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(App)); ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); }
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); }
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."); }
private static int Main(string[] args) { var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)); var result = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); return(result); }
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)); }
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)); }
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))); }); }
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)); }
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); }
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); } }
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)); }
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)); }
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)); }
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); } }
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)); }
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); }
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); }
/// <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; } }
private static IEnumerable <ConsoleCommand> GetCommands() { return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program))); }
public static IEnumerable <ConsoleCommand> GetCommands() => ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
private static int Main(string[] args) { var items = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)); return(ConsoleCommandDispatcher.DispatchCommand(items, args, System.Console.Out)); }
private static IEnumerable <ConsoleCommand> GetCommands(Type start) { return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(start)); }