public CompositeCommand(CommandContext context, Dictionary<string, JToken> commands) { var dictionary = new SortedDictionary<CommandType, JToken>(); foreach (var pair in commands) { CommandType subCommandType; if (Enum.TryParse(pair.Key, true, out subCommandType)) { if (dictionary.ContainsKey(subCommandType)) { Logger.Log(LogLevel.Warning, $"{subCommandType} is defined in config file for several times, the first config is used. NOTE that key is case insensitive."); } else { dictionary.Add(subCommandType, pair.Value); } } else { Logger.Log(LogLevel.Info, $"\"{pair.Key}\" is not a valid command currently supported, ignored."); } } // Order is now defined in SubCommandType Commands = dictionary.Select(s => CommandFactory.GetCommand(s.Key, s.Value, context)).ToList(); }
public ExportCommand(Options options, CommandContext context) { _options = options.ExportCommand; if (_options.IsHelp) { _helpMessage = HelpTextGenerator.GetHelpMessage(options, "export"); } else { options.MetadataCommand = _options; _metadataCommand = new MetadataCommand(options, context); } }
public BuildCommand(Options options, CommandContext context) { var buildCommandOptions = options.BuildCommand; if (buildCommandOptions.IsHelp) { _helpMessage = HelpTextGenerator.GetHelpMessage(options, "build"); } else { Config = MergeConfig(GetConfigFromOptions(buildCommandOptions), context); } if (!string.IsNullOrWhiteSpace(buildCommandOptions.Log)) Logger.RegisterListener(new ReportLogListener(buildCommandOptions.Log)); if (buildCommandOptions.LogLevel.HasValue) Logger.LogLevelThreshold = buildCommandOptions.LogLevel.Value; }
public MetadataCommand(Options options, CommandContext context) { var metadataCommandOptions = options.MetadataCommand; if (metadataCommandOptions.IsHelp) { _helpMessage = HelpTextGenerator.GetHelpMessage(options, "metadata"); } else { Config = MergeConfig(GetConfigFromOptions(metadataCommandOptions), context); InputModels = GetInputModels(Config); } if (!string.IsNullOrWhiteSpace(metadataCommandOptions.Log)) Logger.RegisterListener(new ReportLogListener(metadataCommandOptions.Log)); if (metadataCommandOptions.LogLevel.HasValue) Logger.LogLevelThreshold = metadataCommandOptions.LogLevel.Value; }
public BuildCommand(BuildJsonConfig config, CommandContext context) { Config = MergeConfig(config, context); }
public BuildCommand(JToken value, CommandContext context) : this(CommandFactory.ConvertJTokenTo<BuildJsonConfig>(value), context) { }
public BuildCommand(CommandContext context) : this(new BuildJsonConfig(), context) { }
private BuildJsonConfig MergeConfig(BuildJsonConfig config, CommandContext context) { config.BaseDirectory = context?.BaseDirectory ?? config.BaseDirectory; if (context?.SharedOptions != null) { config.OutputFolder = context.SharedOptions.RootOutputFolder ?? config.OutputFolder; var templates = context.SharedOptions.Templates; if (templates != null) config.Templates = new ListWithStringFallback(templates); var themes = context.SharedOptions.Themes; if (themes != null) config.Themes = new ListWithStringFallback(themes); config.Force |= context.SharedOptions.ForceRebuild; config.Serve |= context.SharedOptions.Serve; config.Port = context.SharedOptions.Port?.ToString(); } return config; }
public PackCommand(Options options, CommandContext context) { _options = options.PackCommand; _rootOptions = options; }
public ServeCommand(Options options, CommandContext context) { _options = options.ServeCommand; _rootOptions = options; }
private MetadataJsonConfig MergeConfig(MetadataJsonConfig config, CommandContext context) { config.BaseDirectory = context?.BaseDirectory ?? config.BaseDirectory; if (context?.SharedOptions != null) { config.OutputFolder = context.SharedOptions.RootOutputFolder ?? config.OutputFolder; config.Force |= context.SharedOptions.ForceRebuild; config.Raw |= context.SharedOptions.PreserveRawInlineComments; } return config; }
public MetadataCommand(MetadataJsonConfig config, CommandContext context) { Config = MergeConfig(config, context); InputModels = GetInputModels(Config); }
public MetadataCommand(JToken value, CommandContext context) : this(CommandFactory.ConvertJTokenTo<MetadataJsonConfig>(value), context) { }
public MetadataCommand(CommandContext context) : this(new MetadataJsonConfig(), context) { }
public HelpCommand(Options options, CommandContext context) { _options = options.HelpCommand; _rootOptions = options; }