11var app = new CommandApp ( ) ;
2+
23app . Configure ( config =>
34{
45 config . SetApplicationName ( "ucll" ) ;
56 config . SetApplicationVersion ( "1.0.0" ) ;
67
7- config . AddCommand < OpenCommand > ( "open" )
8- . WithDescription ( "Open Unity Editor for a project search path or via recent projects prompt" )
9- . WithExample ( "open" )
10- . WithExample ( "open" , "." )
11- . WithExample ( "open" , "path/to/project" )
12- . WithExample ( "open" , "path/to/project" , "--" , "-batchmode" , "-quit" ) ;
8+ config . AddCommand < OpenCommand > ( "open" ) . ConfigureOpen ( ) ;
9+
10+ config . AddBranch ( "project" , command =>
11+ {
12+ command . SetDescription ( "Manage Unity projects" ) ;
13+
14+ command . AddCommand < OpenCommand > ( "open" ) . ConfigureOpen ( parentName : "project" ) ;
1315
14- config . AddCommand < InstallCommand > ( "install" )
15- . WithDescription ( "Install Unity Editor version" )
16- . WithExample ( "install" , "2022.3.10f1" )
17- . WithExample ( "install" , "2022.3.10f1" , "ff3792e53c62" )
18- . WithExample ( "install" , "2022.3.10f1" , "--" , "--module" , "android" ) ;
16+ command . AddCommand < ProjectVersionCommand > ( "version" )
17+ . WithDescription ( "Get Unity version from project search directory or ProjectVersion.txt" )
18+ . WithExample ( "project" , "version" , "path" ) ;
19+ } ) ;
1920
2021 config . AddBranch ( "editor" , command =>
2122 {
23+ command . SetDescription ( "Manage a specific Unity Editor" ) ;
24+
25+ command . AddCommand < InstallCommand > ( "install" )
26+ . WithDescription ( "Install Unity Editor version" )
27+ . WithExample ( "editor" , "install" , "2022.3.10f1" )
28+ . WithExample ( "editor" , "install" , "2022.3.10f1" , "ff3792e53c62" )
29+ . WithExample ( "editor" , "install" , "2022.3.10f1" , "--" , "--module" , "android" ) ;
30+
2231 command . AddCommand < EditorRevisionCommand > ( "revision" )
2332 . WithDescription ( "Get revision for Unity version" )
2433 . WithExample ( "editor" , "revision" , "2022.3.10f1" ) ;
2534
2635 command . AddCommand < EditorPathCommand > ( "path" )
2736 . WithDescription ( "Get installation path for Unity version" )
2837 . WithExample ( "editor" , "path" , "2022.3.10f1" ) ;
29- } ) ;
3038
31- config . AddCommand < ProjectVersionCommand > ( "project-version" )
32- . WithDescription ( "Get Unity version from project search directory or ProjectVersion.txt" )
33- . WithExample ( "project-version" , "path" ) ;
39+ command . AddCommand < InstallationsUsedCommand > ( "used" )
40+ . WithDescription ( "Find all projects using a specific Unity version" )
41+ . WithExample ( "editor" , "used" , "2022.3.10f1" ) ;
42+ } ) ;
3443
35- config . AddBranch ( "installations " , installations =>
44+ config . AddBranch ( "editors " , command =>
3645 {
37- installations . SetDescription ( "Manage and view Unity Editor installations " ) ;
46+ command . SetDescription ( "Manage all installed Unity Editors " ) ;
3847
39- installations . AddCommand < InstallationsOverviewCommand > ( "overview " )
48+ command . AddCommand < InstallationsOverviewCommand > ( "list " )
4049 . WithDescription ( "List installed Unity Editor versions" )
41- . WithExample ( "installations" , "overview" )
42- . WithExample ( "installations" , "overview" , "--parseable" ) ;
43-
44- installations . AddCommand < InstallationsUsedCommand > ( "used" )
45- . WithDescription ( "Find all projects using a specific Unity version" )
46- . WithExample ( "installations" , "used" , "2022.3.10f1" ) ;
50+ . WithExample ( "editors" , "list" )
51+ . WithExample ( "editors" , "list" , "--parseable" ) ;
4752 } ) ;
4853} ) ;
4954
50- return app . Run ( args ) ;
55+ return app . Run ( args ) ;
56+
57+ static class ICommandConfigurationExtensions
58+ {
59+ public static void ConfigureOpen ( this ICommandConfigurator command , string ? parentName = null )
60+ {
61+ string [ ] MakeExample ( params string [ ] args ) => parentName == null ? args : [ parentName , ..args ] ;
62+
63+ command . WithDescription ( "Open Unity Editor for a project search path or via recent projects prompt" )
64+ . WithExample ( MakeExample ( "open" ) )
65+ . WithExample ( MakeExample ( "open" , "." ) )
66+ . WithExample ( MakeExample ( "open" , "path/to/project" ) )
67+ . WithExample ( MakeExample ( "open" , "path/to/project" , "--" , "-batchmode" , "-quit" ) ) ;
68+ }
69+ }
0 commit comments