You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import ArgumentParser
structExample:ParsableCommand{staticvarconfiguration=CommandConfiguration(
abstract:"Some example command to demo bug.",
helpNames:[.long,.customShort("h")])@Option( help:ArgumentHelp("Entries to remove: \"caches\" targets OCI and IPSW caches and \"vms\" targets local VMs."))varentries:String="caches"@Option( help:ArgumentHelp("Remove entries that were last accessed more than n days ago", valueName:"n"))varolderThan:UInt?@Option(help:.hidden)varcacheBudget:UInt?@Option( help:ArgumentHelp("Remove the least recently used entries that do not fit the specified space size budget n, expressed in gigabytes", valueName:"n"))varspaceBudget:UInt?@Flag()vargc:Bool= false
mutatingfunc run()throws{print("Example run")}}
Then build the executable:
swift build
Then source shell completions into FPATH. In my case I do:
Then run ./.build/debug/SAPbug and try triggering various shell completions
(see video).
Expected behavior
$ ./.build/debug/SAPbug example [tab]
--entries -- Entries to remove: "caches" targets OCI and IPSW caches and "vms" targets local VMs.
--help -- Show help information.
--older-than -- Remove entries that were last accessed more than n days ago
--space-budget -- Remove the least recently used entries that do not fit the specified space size budget n, expressed
--version -- Show the version.
--gc
Short options should not be suggested, or alternatively, they should not break
in such a bad way.
Actual behavior
Completions are broken.
Command invocation
$ ./.build/debug/SAPbug example [tab]
--entries
--help
--older-than
--space-budget
--version
-h
-- Entries to remove: "caches" targets OCI and IPSW caches and "vms" targets local VMs.
-- Show help information.
-- Remove entries that were last accessed more than n days ago
-- Remove the least recently used entries that do not fit the specified space size budget n, express
-- Show the version.
--entries
--help
--older-than
--space-budget
--version
-h
-- Entries to remove: "caches" targets OCI and IPSW caches and "vms" targets local VMs.
-- Show help information.
-- Remove entries that were last accessed more than n days ago
-- Remove the least recently used entries that do not fit the specified space size budget n, express
-- Show the version.
--gc
The text was updated successfully, but these errors were encountered:
bartekpacia
changed the title
Zsh shell shell completion is broken when short flags exist
Zsh shell completion is broken when short flags exist
Apr 10, 2024
@bartekpacia Thanks for this report! I've heard of this issue from some others who have oh-my-zsh installed, but I haven't been able to reproduce this myself, even after installing that tool. Do you see this behavior from any other completion scripts that aren't generated by ArgumentParser? Does git auto-complete correctly for you?
@bartekpacia Adding the following command to your .zshrc after source "$ZSH/oh-my-zsh.sh" undoes oh-my-zsh's fuzzy completion settings, which fixes the issue (which exists for other completions, not just those generated by SAP):
Hi,
This is my first issue in this repository. Thank you for creating and maintaining this great package!
Now onto the problem: I discovered a bug with shell completions. Please see video below:
bugdemo.mp4
ArgumentParser version:
Swift version:
Checklist
main
branch of this packageSteps to Reproduce
Use
Zsh
with shell completion enabled.Then create a simple Swift command line app that uses
swift-argument-parser
.Package.swift
Sources/Root.swift
Sources/Example.swift
Then build the executable:
swift build
Then source shell completions into FPATH. In my case I do:
./.build/debug/SAPbug --generate-completion-script zsh > /opt/homebrew/share/zsh/site-functions/_SAPbug && exec zsh
Then run
./.build/debug/SAPbug
and try triggering various shell completions(see video).
Expected behavior
Short options should not be suggested, or alternatively, they should not break
in such a bad way.
Actual behavior
Completions are broken.
Command invocation
The text was updated successfully, but these errors were encountered: