Beispiel #1
0
        public TemplateCommand(TemplateCommandOptions options)
        {
            if (options.Commands == null || options.Commands.Count == 0 || !Enum.TryParse(options.Commands[0], true, out _commandType))
            {
                throw new InvalidOptionException("Neither 'list' nor 'export' is found. You must specify a command type.");
            }
            switch (_commandType)
            {
            case TemplateCommandType.Export:
                _exportTemplateConfig = new ExportTemplateConfig
                {
                    All          = options.All,
                    OutputFolder = options.OutputFolder,
                    Templates    = options.Commands.Skip(1).ToArray()
                };
                if (_exportTemplateConfig.Templates.Length == 0)
                {
                    _exportTemplateConfig.All = true;
                }
                break;
            }
            _assembly = this.GetType().Assembly;
            var templateRegex = new Regex($"{Regex.Escape(_assembly.GetName().Name)}\\.{Regex.Escape(Constants.EmbeddedTemplateFolderName)}\\.([\\S.]+)\\.zip");

            _templates = _assembly.GetManifestResourceNames().Select(s => templateRegex.Match(s)).Where(s => s.Success).Select(s => s.Groups[1].Value).ToArray();
        }
Beispiel #2
0
        public TemplateCommand(TemplateCommandOptions options)
        {
            _options = options;
            if (options.Commands == null || options.Commands.Count == 0 || !Enum.TryParse(options.Commands[0], true, out _commandType))
            {
                throw new InvalidOptionException("Neither 'list' nor 'export' is found");
            }
            switch (_commandType)
            {
            case TemplateCommandType.Export:
                _exportTemplateConfig = new ExportTemplateConfig
                {
                    All          = options.All,
                    OutputFolder = options.OutputFolder,
                    Templates    = options.Commands.Skip(1).ToArray()
                };
                if (_exportTemplateConfig.Templates.Length == 0)
                {
                    _exportTemplateConfig.All = true;
                }
                break;

            default:
                break;
            }
        }
Beispiel #3
0
 public TemplateCommand(TemplateCommandOptions options)
 {
     _options = options;
     if (options.Commands == null || options.Commands.Count == 0 || !Enum.TryParse(options.Commands[0], true, out _commandType))
     {
         throw new InvalidOptionException("Neither 'list' nor 'export' is found. You must specify a command type.");
     }
     switch (_commandType)
     {
         case TemplateCommandType.Export:
             _exportTemplateConfig = new ExportTemplateConfig
             {
                 All = options.All,
                 OutputFolder = options.OutputFolder,
                 Templates = options.Commands.Skip(1).ToArray()
             };
             if (_exportTemplateConfig.Templates.Length == 0)
             {
                 _exportTemplateConfig.All = true;
             }
             break;
         default:
             break;
     }
 }
Beispiel #4
0
 public TemplateCommand(TemplateCommandOptions options)
 {
     _options = options;
     if (options.Commands == null || options.Commands.Count == 0 || !Enum.TryParse(options.Commands[0], true, out _commandType))
     {
         throw new InvalidOptionException("Neither 'list' nor 'export' is found");
     }
     switch (_commandType)
     {
         case TemplateCommandType.Export:
             _exportTemplateConfig = new ExportTemplateConfig
             {
                 All = options.All,
                 OutputFolder = options.OutputFolder,
                 Templates = options.Commands.Skip(1)
             };
             break;
         default:
             break;
     }
 }