-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(completion) - generate shell script in a much more automated way #3981
chore(completion) - generate shell script in a much more automated way #3981
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.
README.md
Outdated
@@ -289,19 +289,19 @@ To turn on auto completion use the following commands: | |||
|
|||
For bash: | |||
```bash | |||
ng completion 1>> ~/.bashrc 2>>&1 | |||
ng completion --bash 1>> ~/.bashrc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the 1
in 1>>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, changed it in completion.ts, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, should take you all of 5 minutes. Please note that README is being moved to wiki.
cc @Brocco
caseBlock + | ||
' *) opts="" ;;'; | ||
|
||
console.log(`###-begin-ng-completion### |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use stripIndent
from common-tags
and indent the whole string? Look at other places where we use it for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
if (commandOptions.all || commandOptions.bash) { | ||
console.log(`_ng_completion() { | ||
local cword pword opts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; use stripIndent
so we keep the indentation in the code (I don't care much about the generated files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, too.
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 generate
command is not fully supported yet.It is being considered for the main
ng
options, however since it does not haveavaliableOptions
but rather an aliasMap, it requires more work.