static void Main(string[] args) { // set the console encoding Console.OutputEncoding = Encoding.UTF8; // load the commands IEnumerable <ConsoleCommand> commands = GetCommands(); int run = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); if (run == 0) { // start the program Console.WriteLine("online"); // download the title blacklist // the bool set the source from where to download the file from TitleBlackList = GetTitleBlackList(false); // the data queue ConcurrentQueue <Tuple <int, string> > wQueue = new ConcurrentQueue <Tuple <int, string> >(); // the work queue ConcurrentQueue <Dictionary <string, string> > oQueue = new ConcurrentQueue <Dictionary <string, string> >(); // add the first url (from the command line) wQueue.Enqueue(new Tuple <int, string>(CustomConsoleCommand.BaseNumber, CustomConsoleCommand.BaseUrl)); // create the threads Thread[] Th = new Thread[nThreads]; for (int i = 0; i < Th.Length; i++) { Th[i] = new Thread(new ThreadStart(() => Work(wQueue, oQueue))); } // start the threads for (int i = 0; i < Th.Length; i++) { Th[i].Start(); } // wait for the worker threads to finish for (int i = 0; i < Th.Length; i++) { Th[i].Join(); } // the data storage until the end // int = number Dictionary <int, Dictionary <string, string> > s_data = new Dictionary <int, Dictionary <string, string> >(); // get the extracted data while (oQueue.IsEmpty == false) { // create a temporary directory Dictionary <string, string> temp = new Dictionary <string, string>(); // get the data bool run_work = oQueue.TryDequeue(out temp); if (run_work) { // send the data to the temporary storage for later processing s_data.Add(Convert.ToInt32(temp["c_id"]), temp); } } // writting the code out string f_path = $"{CustomConsoleCommand.BaseFilePath}\\{CustomConsoleCommand.FileName} {s_data.Keys.Min()} - {s_data.Keys.Max()}.html"; WriteFile(f_path, WriteWebpage(s_data)); Console.WriteLine("offline"); Console.ReadKey(); } }
private static int RegisterCommands(string[] args) { var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)); return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out)); }
static int Main(string[] args) { var commands = GetCommands(); return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out)); }
public static IEnumerable <ConsoleCommand> GetCommands() { return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(ProteoformDatabaseEngine))); }
private static void Main(string[] args) { var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)); ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out, true); }
public override int Run(string[] remainingArguments) { var commands = ProteoformDatabaseEngine.GetCommands(); // USER PROMTS: commands List <string> commandList = new List <string> { "help", "generate", "gptmd", "exit" }; string commandPrompt = String.Join(Environment.NewLine, new string[] { "Choose a command:", "help -- Display help menu for commandline arguments", "generate -- Generate a custom protein XML database", "gptmd -- Enter modifications predicted from first-pass GPTMD search results", "exit -- Exit this program" }); // User prompts: parameters and input files List <string> trueFalseList = new List <string> { "T", "t", "True", "true", "TRUE", "F", "f", "False", "false", "FALSE" }; List <string> trueList = new List <string> { "T", "t", "True", "true", "TRUE" }; List <string> falseList = new List <string> { "F", "f", "False", "false", "FALSE" }; string uniprotXmlPrompt = "Please enter the path for a UniProt XML."; //string ensemblPepAllPrompt = "Please enter the path for an Ensembl peptide fasta"; string methionineOxidationPrompt = ""; string carbamPrompt = ""; string cleavedNTermMetPrompt = ""; string lysineIsotopesPrompt = ""; List <string> lysineOptList = new List <string>(); string maxPtmsPrompt = ""; int maxMaxPtms = 0; string proteoformXmlPrompt = ""; string ensemblFaaPrompt = ""; // RUN COMMANDS after prompting and parsing arguments string command = GetUserResponse(commandPrompt); if (command == "exit") { } else if (command == "help") { ConsoleCommandDispatcher.DispatchCommand(commands, remainingArguments, Console.Out); } else { string[] newargs = new string[0]; if (command == "generate") { bool methionineOxidation = trueList.Contains(GetUserResponse(methionineOxidationPrompt, trueFalseList)); bool carbam = trueList.Contains(GetUserResponse(carbamPrompt, trueFalseList)); bool cleaved_met = trueList.Contains(GetUserResponse(cleavedNTermMetPrompt, trueFalseList)); string lysine_isotopes = GetUserResponse(lysineIsotopesPrompt, lysineOptList); int maxPtms = GetUserResponse(maxPtmsPrompt, Enumerable.Range(0, maxMaxPtms).ToList()); string proteoformXml = GetUserResponse(proteoformXmlPrompt); string uniprotXml = GetUserResponse(uniprotXmlPrompt); string ensemblFaa = GetUserResponse(ensemblFaaPrompt); newargs = new string[7] { command, "-f", proteoformXml, "-u", uniprotXml, "-e", ensemblFaa }; //TODO: test that this works to specify the correct args for ManyConsole } ConsoleCommandDispatcher.DispatchCommand(commands, newargs, Console.Out); // TODO: implement error notification if empty newargs at this point } return(0); }
private static int Main(string[] args) => ConsoleCommandDispatcher.DispatchCommand(Program.GetCommands(), args, Console.Out);
public static int Main() => ConsoleCommandDispatcher.DispatchCommand(Commands, CommandLineParser.Parse(Environment.CommandLine).Skip(1).ToArray(), Console.Out);
public static int Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; string inputFile = null; string outputFile = null; string scriptFile = null; bool showHelp = false; bool quitOnError = true; var p = new OptionSet { { "i|input-file=", "read configuration from {FILE}", value => inputFile = value }, { "o|output-file=", "write results to {FILE}", value => outputFile = value }, { "s|script-file=", "runs commands from {FILE}", value => scriptFile = value }, { "c|continue", "continues when an error occurs while loading the configuration", value => quitOnError = value == null }, { "h|help", "show this help message and exit", value => showHelp = value != null } }; try { p.Parse(args); } catch (OptionException) { ShowHelp(p); return(-1); } if (showHelp || string.IsNullOrEmpty(inputFile)) { ShowHelp(p); return(-1); } HCContext context; TextWriter output = null; try { if (!string.IsNullOrEmpty(outputFile)) { output = new StreamWriter(outputFile); } Console.Write("Reading configuration file \"{0}\"... ", Path.GetFileName(inputFile)); Language language = XmlLanguageLoader.Load(inputFile, quitOnError ? (Action <Exception, string>)null : (ex, id) => { }); Console.WriteLine("done."); context = new HCContext(language, output ?? Console.Out); Console.Write("Compiling rules... "); context.Compile(); Console.WriteLine("done."); Console.WriteLine("{0} loaded.", language.Name); Console.WriteLine(); } catch (IOException ioe) { Console.WriteLine(); Console.WriteLine("IO Error: " + ioe.Message); if (output != null) { output.Close(); } return(-1); } catch (Exception e) { Console.WriteLine(); Console.WriteLine("Load Error: " + e.Message); if (output != null) { output.Close(); } return(-1); } ConsoleCommand[] commands = { new ParseCommand(context), new TracingCommand(context), new TestCommand(context), new StatsCommand(context) }; string input; if (!string.IsNullOrEmpty(scriptFile)) { using (var scriptReader = new StreamReader(scriptFile)) { input = scriptReader.ReadLine(); while (input != null) { if (!input.Trim().StartsWith("#") && input.Trim() != "") { string[] cmdArgs = CommandLineParser.Parse(input); ConsoleCommandDispatcher.DispatchCommand(commands, cmdArgs, context.Out); } input = scriptReader.ReadLine(); } } } else { Console.Write("> "); input = Console.ReadLine(); while (input != null && input.Trim() != "exit") { if (input.Trim().IsOneOf("?", "help")) { ConsoleHelp.ShowSummaryOfCommands(commands, Console.Out); } else { string[] cmdArgs = CommandLineParser.Parse(input); ConsoleCommandDispatcher.DispatchCommand(commands, cmdArgs, context.Out); } Console.Write("> "); input = Console.ReadLine(); } } if (output != null) { output.Close(); } return(0); }
static void Main(string[] args) { var commands = GetCommands(); ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); }
public override int Run(string[] remainingArguments) { var _command = File.ReadAllText(_GetSavedCommandFilePath()); return(ConsoleCommandDispatcher.DispatchCommand(Commands, CommandLineParser.Parse(_command), Console.Out)); }
public static int Main(string[] args) { var commands = GetCommands(); return(ConsoleCommandDispatcher.DispatchCommand(commands, args, System.Console.Out, System.Console.Error)); }
public static System.Collections.Generic.IEnumerable <ConsoleCommand> GetCommands() { return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program))); }
private static IEnumerable <ConsoleCommand> GetCommands() => ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
static int Main(string[] args) { return(ConsoleCommandDispatcher.DispatchCommand(GetCommands(), args, Console.Out)); }
public static void Main(string[] args) { ConsoleCommandDispatcher.DispatchCommand(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(SimpleTracker)), args, Console.Out); }
protected override void RunTool(out object result, IList <object> stdInArgs, IList <string> separateArgs) { byte[] stdinbytes; using (var instream = new MemoryStream()) using (var tempwrite = new StreamWriter(instream)) { if (stdInArgs.Any()) { foreach (var args in stdInArgs) { tempwrite.WriteLine(args); } } tempwrite.Flush(); stdinbytes = instream.ToArray(); } var combinedArg = String.Join(" ", separateArgs); var program = "KeyczarTool"; if (IsRunningOnMono) { combinedArg = "KeyczarTool.exe " + combinedArg; program = "mono"; } Console.WriteLine("{0} {1}", program, combinedArg); var origIn = Console.In; var origOut = Console.Out; using (var inbyteStream = new MemoryStream(stdinbytes)) using (var input = new StreamReader(inbyteStream)) { try { Console.SetIn(input); using (var stream = new MemoryStream()) using (var output = new StreamWriter(stream)) { try { Console.SetOut(output); var commands = KeyczarTool.Program.Commands; var args = separateArgs.Select(it => it.Replace("\"", "")).ToArray(); ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out, app => { app.UsePagerForHelpText = false; }); output.Flush(); result = Encoding.UTF8.GetString(stream.ToArray()); } finally { Console.SetOut(origOut); } } } finally { Console.SetIn(origIn); } } Console.WriteLine(result); }
public static int Main(string[] args) { var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)); return(ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out)); }
public static IEnumerable <ConsoleCommand> GetCommands() { return(ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program))); }
public void quit(string[] args) { var commands = GetCommands(); ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); }