/// <summary> /// Default Constructor /// </summary> /// <param name="model">usage description of the CLI</param> internal CLIArgumentAggregator(CLIUsageModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (model.ArgumentsType == null) { throw new ArgumentNullException(nameof(model)); } this._Model = model; }
/// <summary> /// BUilds the model to map CLI usage /// </summary> /// <returns></returns> public CLIUsageModel BuildModel() { var model = new CLIUsageModel(this._TargetType, this._Options, this._Verbs); foreach (var opt in this._OptionDefinitions) { model.MapOption(opt.Value.LongCode, opt.Key); } foreach (var opt in this._VerbDefinitions) { model.MapVerb(opt.Value.Name, opt.Key); } // get examples ICLIArguments concreteSettings = Activator.CreateInstance(this._TargetType) as ICLIArguments; if (concreteSettings == null) { throw new InvalidOperationException($"Unable to instance {this._TargetType.Name}: is not a valid {typeof(ICLIArguments).Name}"); } concreteSettings.Examples.ToList().ForEach(x => model.AddExample(x)); return(model); }
/// <summary> /// Default Constructor /// </summary> protected UsagePrinter(CLIUsageModel model, string alias) { _Model = model ?? throw new ArgumentNullException(nameof(CLIUsageModel)); _Alias = alias ?? throw new ArgumentNullException(nameof(alias)); }
/// <summary> /// Default Constructor /// </summary> /// <param name="model"></param> /// <param name="alias">Alias for the CLI</param> public StringBuilderUsagePrinter(CLIUsageModel model, string alias) : base(model, alias) { this._MessageBuilder = new StringBuilder(); }
/// <summary> /// Default Constructor /// </summary> public ConsoleUsagePrinter(CLIUsageModel model, string alias) : base(model, alias) { }