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

feat: Add Powershell runtime support #41

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

shannmu
Copy link

@shannmu shannmu commented Jul 4, 2024

To support powershell completion test

path,
home,
config: config_path,
timeout: Duration::from_millis(50),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the timeout is 50ms will get nothing in comptest function.
Because

while let Ok(n) = stream.read(&mut buf) {

the read call is slow for powershell.

@shannmu
Copy link
Author

shannmu commented Jul 4, 2024

I've been working on test code to test support for PowerShell in clap_complete. So adding completest support for PowerShell is necessary.
But I've hit a problem that I haven't figured out yet. It looks like there's some issue between pwsh (PowerShell on Linux) and the PtyProcess crate or the vt100 crate. When I open a real shell in bash using the PATH="xxx" XDG_CONFIG_HOME="xxx" pwsh --nologo command and try exhaustive \t, pwsh works fine. However, there are problems when running in a pty.
Here's the output of pty for the input exhaustive \t:

+ % ����������<�D����� �����<� ��&�D3^V^C% 
    2 + action    complete  global    help      last      quote     value     
    3 + alias     generate  h         hint      pacman    V         version   ∅

I found a possibly related issue in the PowerShell community: PowerShell/PowerShell#14932

// Open the original file and read its content
let mut original_file = OpenOptions::new().read(true).open(&file_path)?;
let mut original_content = Vec::new();
original_file.read_to_end(&mut original_content)?;

Check failure

Code scanning / clippy

use of File::read_to_end Error

use of File::read\_to\_end
// Open the original file and read its content
let mut original_file = OpenOptions::new().read(true).open(&file_path)?;
let mut original_content = Vec::new();
original_file.read_to_end(&mut original_content)?;

Check failure

Code scanning / clippy

use of File::read_to_end Error

use of File::read\_to\_end
@coveralls
Copy link

coveralls commented Jul 5, 2024

Pull Request Test Coverage Report for Build 9790909347

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Totals Coverage Status
Change from base Build 9725894785: 0.0%
Covered Lines: 0
Relevant Lines: 12

💛 - Coveralls

@epage
Copy link
Contributor

epage commented Jul 5, 2024

I have mixed feelings. Most devs will be on Linux so this makes it easy to not regress. However, most contributors to this feature will likely be on Windows and won't be able to test it.

I found a possibly related issue in the PowerShell community: PowerShell/PowerShell#14932

sigh automatically closed issues.

@shannmu
Copy link
Author

shannmu commented Jul 5, 2024

Most people definitely use PowerShell on Windows. Since I'm developing on Linux, my plan is to first support PowerShell on Linux to add tests for PowerShell support in clap_complete. I'll definitely need to support PowerShell on Windows later on.
But now it seems like supporting PowerShell on Linux might not be a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants