chore(completion) - generate shell script in a much more automated way#3981
chore(completion) - generate shell script in a much more automated way#3981catull wants to merge 25 commits into
Conversation
…little tweaking in the case-block.
…ntirely. The options and aliases are generated dynamically. There are options to only produce bash- or zsh-specific code.
|
PR is large, it introduces command options. |
…is no reason we should capture std error and stuff it into .bashrc / .zshrc. Let's just capture std output instead.
Convert function displayCaseBlock() into const caseBlock. Convert let-variables into constants.
… front of each line it writes. Reverting to console.log.
| For bash: | ||
| ```bash | ||
| ng completion 1>> ~/.bashrc 2>>&1 | ||
| ng completion --bash 1>> ~/.bashrc |
There was a problem hiding this comment.
Okay, changed it in completion.ts, too.
| caseBlock + | ||
| ' *) opts="" ;;'; | ||
|
|
||
| console.log(`###-begin-ng-completion### |
There was a problem hiding this comment.
Could you use stripIndent from common-tags and indent the whole string? Look at other places where we use it for an example.
|
|
||
| if (commandOptions.all || commandOptions.bash) { | ||
| console.log(`_ng_completion() { | ||
| local cword pword opts |
There was a problem hiding this comment.
Same here; use stripIndent so we keep the indentation in the code (I don't care much about the generated files).
|
LGTM. Awesome! |
|
Waiting for the e2e tests to complete then I'll merge this in time for the beta |
|
I have a request (which can be a separate PR) to extract the availableOptions into a separate file so it can be used by other things than just completion. And with that add the ability to parse out the availableOptions from blueprints as well. |
|
No I'm fine with this PR as it is today. Mike does that impede your work? |
|
I can open a new issue to introduce a separation of availableOptions / blueprints into, say _.options.ts. |
It requires little tweaking in the case-block. Now the completion shell script is generated out of TypeScript code entirely. The options and aliases are generated dynamically. There are options to only produce bash- or zsh-specific code. Closes angular#3981.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
All the options are taken straight from the commands, aliases as well.
The
ng generatecommand is not fully supported yet.It is being considered for the main
ngoptions, however since it does not haveavaliableOptionsbut rather an aliasMap, it requires more work.