static int Main2(Queue <string> args) { PrintBanner(); var context = FindContext(); string command = ""; if (args.Any()) { command = args.Dequeue(); } switch (command.ToUpperInvariant()) { case "": case "ANALYSE": case "ANALYZE": return(AnalyseCommand.Analyse(context, args)); case "APPLY": return(ApplyCommand.Apply(context, args)); case "HELP": return(HelpCommand.Help(context, args)); default: throw new UserException($"Unrecognised <command>, try `projlint help`"); } }
public AnalyseResult Analyse(AnalyseCommand cmd) { TimeSpan timeToAnalyse; TimeSpan timeToSaveOnDatabase; TimeSpan timeToSerializeOutput; using (var stream = new StreamReader(cmd.TextFileAddress)) { var sw = Stopwatch.StartNew(); var algorithmResult = _algorithm.Analyse(stream); timeToAnalyse = sw.Elapsed; var textContent = File.ReadAllText(cmd.TextFileAddress); var analyse = new Analyse( textFileAddress: cmd.TextFileAddress, textFileContent: textContent, sentences: algorithmResult.Sentences); sw.Restart(); _repository.SaveAnalyse(analyse); timeToSaveOnDatabase = sw.Elapsed; sw.Restart(); var result = _serializer.Serialize(analyse); timeToSerializeOutput = sw.Elapsed; return(new AnalyseResult( result: result, timeToAnalyse: timeToAnalyse, timeToSaveOnDatabase: timeToSaveOnDatabase, timeToSerializeOutput: timeToSerializeOutput)); } }
public string Visit(AnalyseCommand command) { return(command.File.FullName); }