1+ internal class CompletionCommand : BaseCommand < CompletionSettings >
2+ {
3+ protected override int ExecuteImpl ( CompletionSettings settings )
4+ {
5+ if ( settings . Shell . Equals ( "zsh" , StringComparison . OrdinalIgnoreCase ) )
6+ {
7+ Console . WriteLine ( GenerateZshCompletion ( ) ) ;
8+ return 0 ;
9+ }
10+
11+ WriteError ( $ "Unsupported shell: { settings . Shell } . Currently only 'zsh' is supported.") ;
12+ return 1 ;
13+ }
14+
15+ private static string GenerateZshCompletion ( )
16+ {
17+ return """
18+ #compdef ucll
19+
20+ _ucll() {
21+ local -a commands
22+ commands=(
23+ 'open:Open Unity Editor for a project search path or via recent projects prompt'
24+ 'create:Create a new Unity project'
25+ 'project-path:Get Unity project root directory from search path or via recent projects prompt'
26+ 'editor-revision:Get revision for Unity version'
27+ 'editor-path:Get installation path for Unity version'
28+ 'editor-modules:List installed modules for Unity version'
29+ 'project-version:Get Unity version from project search directory or ProjectVersion.txt'
30+ 'version-usage:List installed Unity Editor versions and indicate which ones are used by projects'
31+ 'projects-using:Find all projects that use a specific Unity version'
32+ 'install:Install Unity Editor version'
33+ 'install-missing:Install all Unity versions that are used by projects but not currently installed'
34+ 'uninstall-unused:Uninstall all Unity versions that are not used by any projects'
35+ 'upm-git-url:Generate a git URL for Unity Package Manager from a Unity project'
36+ 'hub:Execute Unity Hub interactively or with additional CLI arguments'
37+ 'completion:Generate shell completion scripts'
38+ )
39+
40+ _arguments -C \
41+ '1: :->command' \
42+ '*::arg:->args'
43+
44+ case "$state" in
45+ command)
46+ _describe 'command' commands
47+ ;;
48+ args)
49+ case $words[1] in
50+ open)
51+ _arguments \
52+ '(-f --favorite --favorites)'{-f,--favorite,--favorites}'[Use favorite projects only]' \
53+ '(-c --code-editor)'{-c,--code-editor}'[Open the solution file in the default code editor]' \
54+ '--dry-run[Show what would be executed without actually running mutating commands]'
55+ ;;
56+ create)
57+ _arguments \
58+ '(-m --minimal)'{-m,--minimal}'[Creates a bare-minimum project (fast)]' \
59+ '--dry-run[Show what would be executed without actually running mutating commands]' \
60+ '1:project path:_directories' \
61+ '2:version:'
62+ ;;
63+ project-path)
64+ _arguments \
65+ '(-f --favorite --favorites)'{-f,--favorite,--favorites}'[Use favorite projects only]'
66+ ;;
67+ editor-revision)
68+ _arguments \
69+ '1:version:'
70+ ;;
71+ editor-path)
72+ _arguments \
73+ '1:version:'
74+ ;;
75+ editor-modules)
76+ _arguments \
77+ '1:version:'
78+ ;;
79+ project-version)
80+ _arguments \
81+ '(-f --favorite --favorites)'{-f,--favorite,--favorites}'[Use favorite projects only]'
82+ ;;
83+ version-usage)
84+ _arguments \
85+ '(-p --plaintext --plain)'{-p,--plaintext,--plain}'[Output in a simple machine-parseable format]' \
86+ '(-m --modules)'{-m,--modules}'[Include installed modules for each editor version]'
87+ ;;
88+ projects-using)
89+ _arguments \
90+ '1:version:'
91+ ;;
92+ install)
93+ _arguments \
94+ '--dry-run[Show what would be executed without actually running mutating commands]' \
95+ '1:version:' \
96+ '2:changeset:'
97+ ;;
98+ install-missing)
99+ _arguments \
100+ '--dry-run[Show what would be executed without actually running mutating commands]'
101+ ;;
102+ uninstall-unused)
103+ _arguments \
104+ '--dry-run[Show what would be executed without actually running mutating commands]'
105+ ;;
106+ upm-git-url)
107+ _arguments \
108+ '(-f --favorite --favorites)'{-f,--favorite,--favorites}'[Use favorite projects only]'
109+ ;;
110+ hub)
111+ # Hub command accepts arbitrary arguments, no specific completion
112+ ;;
113+ completion)
114+ _arguments \
115+ '1:shell:(zsh)'
116+ ;;
117+ esac
118+ ;;
119+ esac
120+ }
121+
122+ _ucll
123+ """ ;
124+ }
125+ }
0 commit comments