Ejemplo n.º 1
0
 private MetadataJsonConfig ParseOptions(MetadataCommandOptions options)
 {
     string configFile;
     if (TryGetJsonConfig(options.Projects, out configFile))
     {
         var config = CommandUtility.GetConfig<MetadataConfig>(configFile).Item;
         if (config == null) throw new DocumentException($"Unable to find metadata subcommand config in file '{configFile}'.");
         config.BaseDirectory = Path.GetDirectoryName(configFile);
         config.OutputFolder = options.OutputFolder;
         foreach (var item in config)
         {
             item.Raw |= options.PreserveRawInlineComments;
             item.Force |= options.ForceRebuild;
             item.ShouldSkipMarkup |= options.ShouldSkipMarkup;
             item.FilterConfigFile = options.FilterConfigFile ?? item.FilterConfigFile;
         }
         return config;
     }
     else
     {
         var config = new MetadataJsonConfig();
         config.Add(new MetadataJsonItemConfig
         {
             Force = options.ForceRebuild,
             ShouldSkipMarkup = options.ShouldSkipMarkup,
             Destination = options.OutputFolder,
             Raw = options.PreserveRawInlineComments,
             Source = new FileMapping(new FileMappingItem(options.Projects.ToArray())) { Expanded = true },
             FilterConfigFile = options.FilterConfigFile
         });
         return config;
     }
 }
Ejemplo n.º 2
0
        private static MetadataJsonConfig GetConfigFromOptions(MetadataCommandOptions options)
        {
            string jsonConfig;

            // Glob pattern is not allowed for command line options
            if (TryGetJsonConfig(options.Projects, out jsonConfig))
            {
                var command = (MetadataCommand)CommandFactory.ReadConfig(jsonConfig, null).Commands.FirstOrDefault(s => s is MetadataCommand);
                if (command == null)
                {
                    throw new DocumentException($"Unable to find {CommandType.Build} subcommand config in file '{Constants.ConfigFileName}'.");
                }
                var config = command.Config;
                config.BaseDirectory = Path.GetDirectoryName(jsonConfig);
                config.OutputFolder  = options.OutputFolder;
                foreach (var item in config)
                {
                    item.Raw   |= options.PreserveRawInlineComments;
                    item.Force |= options.ForceRebuild;
                }
                return(config);
            }
            else
            {
                var config = new MetadataJsonConfig();
                config.Add(new MetadataJsonItemConfig
                {
                    Force       = options.ForceRebuild,
                    Destination = options.OutputFolder,
                    Raw         = options.PreserveRawInlineComments,
                    Source      = new FileMapping(new FileMappingItem()
                    {
                        Files = new FileItems(options.Projects)
                    })
                    {
                        Expanded = true
                    }
                });
                return(config);
            }
        }
Ejemplo n.º 3
0
 public MetadataCommand(MetadataCommandOptions options)
 {
     Config = ParseOptions(options);
     EnvironmentContext.BaseDirectory = Path.GetFullPath(string.IsNullOrEmpty(Config.BaseDirectory) ? Directory.GetCurrentDirectory() : Config.BaseDirectory);
     InputModels = GetInputModels(Config);
 }
Ejemplo n.º 4
0
 public MetadataCommand(MetadataCommandOptions options)
 {
     Config = ParseOptions(options);
     InputModels = GetInputModels(Config);
 }
Ejemplo n.º 5
0
 private static MetadataJsonConfig GetConfigFromOptions(MetadataCommandOptions options)
 {
     string jsonConfig;
     // Glob pattern is not allowed for command line options
     if (TryGetJsonConfig(options.Projects, out jsonConfig))
     {
         var command = (MetadataCommand)CommandFactory.ReadConfig(jsonConfig, null).Commands.FirstOrDefault(s => s is MetadataCommand);
         if (command == null) throw new DocumentException($"Unable to find {CommandType.Build} subcommand config in file '{Constants.ConfigFileName}'.");
         var config = command.Config;
         config.BaseDirectory = Path.GetDirectoryName(jsonConfig);
         config.OutputFolder = options.OutputFolder;
         foreach (var item in config)
         {
             item.Raw |= options.PreserveRawInlineComments;
             item.Force |= options.ForceRebuild;
         }
         return config;
     }
     else
     {
         var config = new MetadataJsonConfig();
         config.Add(new MetadataJsonItemConfig
         {
             Force = options.ForceRebuild,
             Destination = options.OutputFolder,
             Raw = options.PreserveRawInlineComments,
             Source = new FileMapping(new FileMappingItem() { Files = new FileItems(options.Projects) }) { Expanded = true }
         });
         return config;
     }
 }