Skip to content
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

Provide option to disable autocompletion #24582

Open
NCC1701M opened this issue Jan 20, 2023 · 16 comments
Open

Provide option to disable autocompletion #24582

NCC1701M opened this issue Jan 20, 2023 · 16 comments
Labels
area: angular/cli feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature

Comments

@NCC1701M
Copy link

NCC1701M commented Jan 20, 2023

Which @angular/* package(s) are relevant/related to the feature request?

No response

Description

If you developing an angular web app in an dev container every time the container is created or rebuild and you are running the ng command for the first time, the angular cli asks:

? Would you like to enable autocompletion? This will set up your terminal so pressing TAB while typing Angular CLI commands will show possible options and autocomplete arguments. (Enabling autocompletion will modify
configuration files in your home directory.)

You can activate this "feature" but there is no way to disable it proactive.

You could run the command ng config -g cli.completion.prompted truebut if this is the first execution of the angular cli this only lead to the question if I want to enable autocompletion. So this isn't a solution.

Proposed solution

Because the user has the possibility to opt this feature out when the angular cli asks you if you want to enable the autocompletion and because there is an command to enable this without being asked there should also be to possibility to disable this feature with an command like

ng completion disable

Alternatives considered

As an alternative you could also make the global configuration settings

{
  "cli": {
    "completion": {
      "prompted": true
    }
  }
}

also available in the angular.json file.

@JoostK JoostK transferred this issue from angular/angular Jan 20, 2023
@alan-agius4 alan-agius4 added feature Issue that requests a new feature area: angular/cli and removed feature Issue that requests a new feature labels Jan 20, 2023
@alan-agius4
Copy link
Collaborator

I seems that you are describing two problems here.

Disable autocomplete when it has been enabled
Currently indeed there is no command to disable autocomplete once enabled. This does require users to remove source <(ng completion script) from their bashrc or zshrc manually.

Disable ng completion question (Which appears to be the main reason why this issue has been opened)
In this case using ng config -g cli.completion.prompted true is the right approach.

@NCC1701M
Copy link
Author

Disable autocomplete when it has been enabled Currently indeed there is no command to disable autocomplete once enabled. This does require users to remove source <(ng completion script) from their bashrc or zshrc manually.

Well this is something what should automatically be resolved with an command like ng completion disable

Disable ng completion question (Which appears to be the main reason why this issue has been opened) In this case using ng config -g cli.completion.prompted true is the right approach.

I disagree ng config -g cli.completion.prompted true isn't the right approach - apart from the fact that it does not working right now. The right approach would be to add two arguments to the ng completion command: enable and disable. This would enable anyone to turn the feature on or off at any time.

@alan-agius4 alan-agius4 added the feature Issue that requests a new feature label Jan 20, 2023
@alan-agius4 alan-agius4 changed the title Option to disable ng completion question Provide option to disable autocompletion Jan 20, 2023
@alan-agius4
Copy link
Collaborator

I disagree ng config -g cli.completion.prompted true isn't the right approach - apart from the fact that it does not working right now.

No really following what what you mean that this does not work. I just tried it and it did work as expected.

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jan 20, 2023
@angular-robot
Copy link
Contributor

angular-robot bot commented Jan 20, 2023

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@NCC1701M
Copy link
Author

NCC1701M commented Jan 20, 2023

No really following what what you mean that this does not work. I just tried it and it did work as expected.

Please take a look at the attached gif. This is a totally new devcontainer no ng command has been executed before. ng config will be the first run (like it would be if you are trying to automatically disable the feature).

On the left you will see the .angular-config.json on the right is the .bashrc file. I run the command and what happens is, that angular asks if I want to enable the autocomplete feature. That should not be happen, because so the feature can not be disabled without user interaction.

ng-complete

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jan 20, 2023

Since there is no completion config and the terminal is interactive (supports TTY) you get prompted the question when you run ng config the first time.

If you want to disable user interactivity completely even when the terminal supports interactivity you can use NG_FORCE_TTY=false environment variable.

@NCC1701M
Copy link
Author

But this could only be a workaround. A reasonable command to enable and disable the feature should be the solution.

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 28, 2023

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Mar 20, 2023

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Mar 20, 2023
@Dzivo
Copy link

Dzivo commented Apr 2, 2023

I have the same problem everytime i rebuild container i forget that i have to enable this can we get option in the config

@dgp1130
Copy link
Collaborator

dgp1130 commented May 9, 2023

@alan-agius4, we have an exception to the analytics prompt for ng analytics disable. I'm wondering if we should do something like that for ng config for autocomplete?

I agree that running ng config cli.completion.prompted true is probably the right solution, we just need to make sure that doesn't itself prompt for completion setup.

NG_FORCE_TTY=false would probably work, but I don't think we generally consider that public API?

@dgp1130
Copy link
Collaborator

dgp1130 commented May 9, 2023

Another approach would be to actually set up autocompletion automatically in your container. We do check to see if it's set up before prompting, so I think if you just run ng completion first, it should hide this prompt. That also has the benefit that when working in the container you get the benefits of autocompletion.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 9, 2023

@alan-agius4, we have an exception to the analytics prompt for ng analytics disable. I'm wondering if we should do something like that for ng config for autocomplete?

That sounds reasonable, we just need to add config to:

if (command === 'update' || command === 'completion') {

NG_FORCE_TTY=false would probably work, but I don't think we generally consider that public API?

That is indeed correct.

@danscalamogna
Copy link

Maybe I am missing something. but why not just add the relevant line to the bashrc file in the docker build?

ARG USERNAME=myuser
RUN SOURCE="source <(ng completion script)" \
    && echo "$SOURCE" >> "/home/$USERNAME/.bashrc"

After rebuilding the container, I can run the cli commands without getting prompted and autocompletion is working.

@NCC1701M
Copy link
Author

NCC1701M commented Jun 7, 2023

Maybe I am missing something. but why not just add the relevant line to the bashrc file in the docker build?

ARG USERNAME=myuser
RUN SOURCE="source <(ng completion script)" \
    && echo "$SOURCE" >> "/home/$USERNAME/.bashrc"

After rebuilding the container, I can run the cli commands without getting prompted and autocompletion is working.

I didn't want to enable autocompletion, I want a command to disable it

@danscalamogna
Copy link

My mistake - I thought you wanted to avoid being prompted every time you rebuilt the container. I did not realize you wanted to disable it altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: angular/cli feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

5 participants