44using System . CommandLine ;
55using System . CommandLine . Builder ;
66using System . CommandLine . Help ;
7- using System . CommandLine . Invocation ;
8- using System . CommandLine . IO ;
7+ using System . CommandLine . NamingConventionBinder ;
98using System . CommandLine . Parsing ;
109using System . IO ;
1110using System . Linq ;
@@ -60,34 +59,30 @@ public static Task<int> Main(string[] args)
6059
6160 return new CommandLineBuilder ( rootCommand )
6261 . UseDefaults ( )
63- . UseHelpBuilder ( ctx => new CustomHelpBuilder ( ctx . Console ) )
62+ . UseHelp ( help => help . HelpBuilder . CustomizeLayout ( GetHelpLayout ) )
6463 . Build ( ) . InvokeAsync ( args ) ;
6564 }
6665
67- private sealed class CustomHelpBuilder : HelpBuilder
66+ private static IEnumerable < HelpSectionDelegate > GetHelpLayout ( HelpContext _ )
6867 {
69- public CustomHelpBuilder ( IConsole console ) : base ( console )
68+ yield return ctx => { ctx . Output . WriteLine ( "DepotDownloader" ) ; } ;
69+ yield return ctx =>
7070 {
71- }
72-
73- protected override void AddUsage ( ICommand command )
74- {
75- if ( command is not RootCommand )
76- return ;
77-
78- Console . Out . WriteLine ( @$ "Examples:
71+ ctx . Output . WriteLine ( @$ "Examples:
7972 - downloading one or all depots for an app:
80- { command . Name } --app <id> [--depot <id> [--manifest <id>]] [--username <username> [--password <password>]]
73+ { ctx . Command . Name } --app <id> [--depot <id> [--manifest <id>]] [--username <username> [--password <password>]]
8174
8275 - downloading a workshop item using pubfile id:
83- { command . Name } --app <id> --pubfile <id> [--username <username> [--password <password>]]
76+ { ctx . Command . Name } --app <id> --pubfile <id> [--username <username> [--password <password>]]
8477
8578 - downloading a workshop item using ugc id:
86- { command . Name } --app <id> --ugc <id> [--username <username> [--password <password>]]"
79+ { ctx . Command . Name } --app <id> --ugc <id> [--username <username> [--password <password>]]"
8780 ) ;
88-
89- Console . Out . WriteLine ( ) ;
90- }
81+ } ;
82+ yield return HelpBuilder . Default . CommandArgumentsSection ( ) ;
83+ yield return HelpBuilder . Default . OptionsSection ( ) ;
84+ yield return HelpBuilder . Default . SubcommandsSection ( ) ;
85+ yield return HelpBuilder . Default . AdditionalArgumentsSection ( ) ;
9186 }
9287
9388 public class InputModel
@@ -100,14 +95,14 @@ public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? u
10095 Manifests = manifest ;
10196 UgcId = ugc ;
10297 PublishedFileIds = pubfile ;
103- Branch = EnsureNonEmpty ( branch ) ;
104- BranchPassword = EnsureNonEmpty ( branchPassword ) ;
98+ Branch = branch ;
99+ BranchPassword = branchPassword ;
105100 OperatingSystems = os ;
106101 Architectures = arch ;
107102 Languages = language ;
108103 LowViolence = lowViolence ;
109- Username = EnsureNonEmpty ( username ) ;
110- Password = EnsureNonEmpty ( password ) ;
104+ Username = username ;
105+ Password = password ;
111106 RememberPassword = rememberPassword ;
112107 Directory = directory ;
113108 FileList = fileList ;
@@ -118,13 +113,6 @@ public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? u
118113 MaxDownloads = maxDownloads ;
119114 LoginId = loginId ;
120115 }
121-
122- // Workaround for https://github.com/dotnet/command-line-api/issues/1244
123- private static string ? EnsureNonEmpty ( string ? s )
124- {
125- return s == string . Empty ? null : s ;
126- }
127-
128116 public bool Debug { get ; }
129117
130118 public uint AppId { get ; }
0 commit comments