internal ToolConsoleManager(TextWriter writer, TextWriter errorWriter = null) : base($"{typeof(ToolConsoleManager).Namespace}.Tool", writer , errorWriter: errorWriter) { PrivateFactories = new ManagerFactories(this); VersionSwitch = Options.AddSwitch("version", OnVersion, "Shows the version of the tool."); // TODO: TBD: do we need to do a $"nameof(Operation)" ? or would $"{Operation}" be sufficient? Operation = Options.AddVariable <OperationKind?>("operation".MaySpecify() , $"[ {nameof(Clean)} | {nameof(Generate)} ]" + $", specify the operation the tool should perform. Default Operation is {nameof(Generate)}."); /* While, technically, we `MustSpecify´ Project, Output, and so on, only when the * Tool Operation is Generate. However, as an OptionSet, we only `MaySpecify´ the * options. We will further vet the Error Levels independently further in. */ ProjectDirectory = Options.AddVariable <string>("p|project".MaySpecify(), "Project directory absolute path."); OutputDirectory = Options.AddVariable <string>("o|output".MaySpecify(), "Generated source files output directory."); IntermediateAssembliesRegistryFileName = Options.AddVariable <string>("a|assemblies".MaySpecify(), "JSON formatted intermediate assemblies registry file name."); IntermediateGeneratedRegistryFileName = Options.AddVariable <string>("g|generated".MaySpecify(), "JSON formatted intermediate generated registry file name."); SourcePathList = Options.AddVariableList <string>("src|source".MaySpecify(), "Source paths included during compilation."); ReferencePathList = Options.AddVariableList <string>("r|reference".MaySpecify(), "Paths to assemblies being referenced."); PreprocessorSymbolsList = Options.AddVariableList <string>("d|define".MaySpecify(), "Paths to preprocessor symbols."); GeneratorSearchPathList = Options.AddVariableList <string>("s|search".MaySpecify(), "Paths to folders that may contain generator assemblies."); // Which we should be able to unit test this as well, given our approach. ResponseFile = Options.AddVariable <string>("response".MaySpecify(), "Processes argument input from a new line delimited response file."); Levels = new ErrorLevelCollection { // TODO: TBD: and to be fair, we may consider an NConsole version that allows for null message factory... // No message should ever be relayed, this should allow --version to short-circuit the rest. { DefaultErrorLevel, () => VersionSwitch, () => Empty }, // TODO: TBD: might do the same for a Help `--help´ or `--?´ option as for Version `--version´... { 1, () => PrivateOperation == Generate && !SourcePathList.Values.Any(), () => NoSourceFilesSpecified }, { 2, () => IsNullOrEmpty(OutputDirectory.Value), () => OutputDirectoryMustBeSpecified }, { 3, () => ServiceException != null, RenderServiceException }, DefaultErrorLevel }; }