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 completion for PowerShell #261

Closed
waldekmastykarz opened this issue Jan 19, 2018 · 7 comments
Closed

Provide completion for PowerShell #261

waldekmastykarz opened this issue Jan 19, 2018 · 7 comments

Comments

@waldekmastykarz
Copy link
Member

waldekmastykarz commented Jan 19, 2018

When using the CLI in non-immersive mode in PowerShell, provide completion for commands and their options.

Additional information:
https://twitter.com/lzybkr/status/954359342001614849
https://twitter.com/lzybkr/status/954363715213672449
https://github.com/lzybkr/TabExpansionPlusPlus/blob/master/WindowsExe.ArgumentCompleters.ps1
https://github.com/lzybkr/TabExpansionPlusPlus

@waldekmastykarz
Copy link
Member Author

I have a working PoC. @VelinGeorgiev, @garrytrinder would you mind giving it a try to see if I haven't missed anything?

  1. Grab https://github.com/waldekmastykarz/office365-cli/tree/pwsh-completion
  2. npm run build
  3. o365 --completion:pwsh:setup
  4. Follow the instructions
  5. Start PowerShell
  6. Type o365[SPACE][TAB] > you should get list of suggestions for all commands in the CLI

Please experiment with the different combinations to check that we have everything that we need.

@garrytrinder
Copy link
Member

I'm struggling at step 4.

I get the Add to your PowerShell profile: message and the Register-O365CLICompletion.ps1 file is generated but not sure where my profile file is...

Executing $PROFILE in pwsh returns /Users/garrytrinder/.config/powershell/Microsoft.PowerShell_profile.ps1 as the profile location but the powershell folder doesn't seem to exist in the .config directory.

Any ideas?

I also can't change to the powershell directory in a terminal session.

@waldekmastykarz
Copy link
Member Author

It could be that the file doesn't exist and you need to create it yourself. See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7 for more info.

@garrytrinder
Copy link
Member

Thanks, I’ll take a look later this evening 👍🏻

@garrytrinder
Copy link
Member

garrytrinder commented Jan 25, 2020

Working great @waldekmastykarz 👏🏻

image

For completeness these were the steps taken to setup my pwsh profile and completion

  1. pwsh
  2. if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force}
  3. nano $PROFILE
  4. Add Register-O365CLICompletion.ps1 file location to profile and save
  5. exit
  6. pwsh
  7. o365[SPACE][TAB]

@waldekmastykarz
Copy link
Member Author

Awesome! Thanks for checking it out. What would be a proper way to have users set it up? I had a look and it seems like the profile path is not exposed in node in any way. We could ask user to pass it as an argument, o365 --completion:pwsh:setup --path $profile and then ensure that the file exists and append the reference to our completion to it or we could leave it be for now and describe it in the docs. What do you think?

@garrytrinder
Copy link
Member

No problem, happy to help 😊

Passing $PROFILE as a param would be a nice user experience, and we can explain why we need this in the docs.

I expect that this will be a feature that will get a lot of attention from users so making the process easy as possible, i.e. automating the manual steps described in the previous comment, will help its usage.

waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Jan 30, 2020
waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Feb 2, 2020
waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Feb 2, 2020
waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Feb 2, 2020
waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Feb 3, 2020
@waldekmastykarz waldekmastykarz added this to the v2.7 milestone Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants