From 255ef78216f7b39634617158c3c1dab5e4f1adec Mon Sep 17 00:00:00 2001 From: Gang Wang Date: Thu, 27 Oct 2022 03:21:49 +0000 Subject: [PATCH] Improve based on the comments --- docs/Reserved-Aliases.md | 127 ++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 47 deletions(-) diff --git a/docs/Reserved-Aliases.md b/docs/Reserved-Aliases.md index c61f364f14f..5fab65944e5 100644 --- a/docs/Reserved-Aliases.md +++ b/docs/Reserved-Aliases.md @@ -1,37 +1,54 @@ ### Reference for dotnetcli.host.json -Generally the name of parameter symbol is the long name and its first character is the short name. Prefixing long name with `--` as long alias and prefixing short name with `-` are the aliases for the parameter symbol listed in the template options. -With `dotnetcli.host.json` file we can change long alias and short alias of the template option and its visibility. `dotnetcli.host.json` is located at the same directory as template.json file. It has the following configuration. -- symbolsInfo -It has a collection of the name of specified parameter symbol in template.json with corresponding long or short name to override original ones and the visibility of the template option. - - longName - - shortName - Empty means short alias should not be used. - - isHidden - True if hiding the parameter in CLI. -- usageExamples -It's an array of usage exmples. Currently it's not used and please track on issue [#3262](https://github.com/dotnet/templating/issues/3262). +In `dotnet new` the parameter symbols are exposed as additional template options that can be passed to the command. Generally, `dotnet new` uses the name of parameter symbol to generate the long and the short alias for the option: +- The long alias is a parameter symbol name with `--` prefix. +- The short alias is a parameter symbol name first character with `-` prefix. -The following examples are several cases when using `dotnetcli.host.json`. +Note that the aliases are case sensitive. + +With `dotnetcli.host.json` file we can change long alias and short alias of the template option and its visibility. `dotnetcli.host.json` is located at the same directory as template.json file. It has the following configuration: +- `symbolsInfo` +It has a collection of the name of specified parameter symbol in template.json with corresponding long or short aliases to override original ones and the visibility of the template option. + - `longName` - overrides the long alias for the parameter symbol. + - `shortName` - overrides the short alias for the parameter symbol. Empty means short alias should not be used. + - `isHidden` - `true` if the parameter should be hidden in `dotnet new`. +- `usageExamples` - not used; see [#3262](https://github.com/dotnet/templating/issues/3262) for more details. + +In case when option assignment results in duplicate options, `--param:` prefix is used for the long alias and short alias is generated from the beginning of the symbol's name till the one which can form a unique short name with `-` prefix or `-p:` prefix is used. ##### Examples -Override original long alias `--TargetFrameworkOverride` with `--targetframework` and override short alias `-T` with `-tf`. And this template option is hidden in CLI help information. +##### Example 1 +Overrides original long alias `--TargetFrameworkOverride` with `--targetframework` and overrides short alias `-T` with `-tf`. ``` { "$schema": "http://json.schemastore.org/dotnetcli.host", "symbolInfo": { "TargetFrameworkOverride": { - "isHidden": "true", "longName": "targetframework", "shortName": "tf" - }, - }, - "usageExamples": [ - "--targetframework net7.0", - "-fr net7.0" - ] + } + } +} +``` +Part of the output of `dotnet new