예제 #1
0
        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();
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }
예제 #5
0
 public BuildCommand(BuildJsonConfig config, CommandContext context)
 {
     Config = MergeConfig(config, context);
 }
예제 #6
0
 public BuildCommand(JToken value, CommandContext context) : this(CommandFactory.ConvertJTokenTo<BuildJsonConfig>(value), context)
 {
 }
예제 #7
0
 public BuildCommand(CommandContext context) : this(new BuildJsonConfig(), context)
 {
 }
예제 #8
0
 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;
 }
예제 #9
0
 public PackCommand(Options options, CommandContext context)
 {
     _options = options.PackCommand;
     _rootOptions = options;
 }
예제 #10
0
 public ServeCommand(Options options, CommandContext context)
 {
     _options = options.ServeCommand;
     _rootOptions = options;
 }
예제 #11
0
 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;
 }
예제 #12
0
 public MetadataCommand(MetadataJsonConfig config, CommandContext context)
 {
     Config = MergeConfig(config, context);
     InputModels = GetInputModels(Config);
 }
예제 #13
0
 public MetadataCommand(JToken value, CommandContext context) : this(CommandFactory.ConvertJTokenTo<MetadataJsonConfig>(value), context)
 {
 }
예제 #14
0
 public MetadataCommand(CommandContext context) : this(new MetadataJsonConfig(), context)
 {
 }
예제 #15
0
 public HelpCommand(Options options, CommandContext context)
 {
     _options = options.HelpCommand;
     _rootOptions = options;
 }