diff --git a/README.md b/README.md index 3db7465db..390b91116 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ One rare cases where this might be useful — as opposed to using a config file Each subcommand generally accepts the same options and syntax, and they mirror the options and parameters from the configuration file: * `--output FILE` or `-o FILE`: set the file where to write the generated code. If omitted, the generated code will be printed on `stdout`. -* `--template NAME` or `-t NAME`: define the Stencil template to use (by name, see [here for more info](Documentation/templates)) to generate the output. +* `--templateName NAME` or `-n NAME`: define the Stencil template to use (by name, see [here for more info](Documentation/templates)) to generate the output. * `--templatePath PATH` or `-p PATH`: define the Stencil template to use, using a full path. * Note: you should specify one and only one template when invoking SwiftGen. You have to use either `-t` or `-p` but should not use both at the same time (it wouldn't make sense anyway and you'll get an error if you try) * Each command supports multiple input files (or directories where applicable). diff --git a/Sources/SwiftGen/Commander/ParserCLICommands.swift b/Sources/SwiftGen/Commander/ParserCLICommands.swift index 4c134783c..7daf70dcc 100644 --- a/Sources/SwiftGen/Commander/ParserCLICommands.swift +++ b/Sources/SwiftGen/Commander/ParserCLICommands.swift @@ -9,10 +9,20 @@ import PathKit import StencilSwiftKit import SwiftGenKit -private let templateNameOption = Option( +// deprecated option +private let deprecatedTemplateNameOption = Option( "template", default: "", flag: "t", + description: """ + DEPRECATED, use `--templateName` instead + """ +) + +private let templateNameOption = Option( + "templateName", + default: "", + flag: "n", description: """ The name of the template to use for code generation. \ See `swiftgen templates list` for a list of available names @@ -36,18 +46,20 @@ extension ParserCLI { func command() -> CommandType { return Commander.command( outputOption, + deprecatedTemplateNameOption, templateNameOption, templatePathOption, paramsOption, VariadicArgument("PATH", description: self.pathDescription, validator: pathsExist) - ) { output, templateName, templatePath, parameters, paths in + ) { output, oldTemplateName, templateName, templatePath, parameters, paths in try ErrorPrettifier.execute { let parser = try self.parserType.init(options: [:]) { msg, _, _ in logMessage(.warning, msg) } try parser.parse(paths: paths) - let templateRef = try TemplateRef(templateShortName: templateName, + let resolvedlTemplateName = templateName.isEmpty ? oldTemplateName : templateName + let templateRef = try TemplateRef(templateShortName: resolvedlTemplateName, templateFullPath: templatePath) let templateRealPath = try templateRef.resolvePath(forSubcommand: self.templateFolder)