File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -129,9 +129,14 @@ static IEnumerable<Content> ParseContents(IEnumerable<string> args)
129129 }
130130 }
131131
132- static void Help ( )
132+ void Help ( )
133133 {
134- Console . WriteLine ( "https [method] [uri] [options] [content]" ) ;
134+ var stream = _stdout ( ) ;
135+ var writer = new StreamWriter ( stream ) { AutoFlush = true } ;
136+ writer . WriteLine ( "https [method] [uri] [options] [content]" ) ;
137+ writer . WriteLine ( "For example https put httpbin.org/put hello=world" ) ;
138+ writer . WriteLine ( "" ) ;
139+ writer . Flush ( ) ;
135140 }
136141
137142 static void AddHeaders ( HttpRequestMessage request , IEnumerable < Content > contents )
@@ -173,7 +178,19 @@ public async Task<int> RunAsync(string[] args)
173178 return 1 ;
174179 }
175180
176- if ( ! Command . TryParse ( args [ 0 ] , args [ 1 ] , out var command ) )
181+ var command = default ( Command ) ;
182+ if ( args . Length > 1 )
183+ {
184+ if ( ! Command . TryParse ( args [ 0 ] , args [ 1 ] , out command ) )
185+ {
186+ if ( ! Command . TryParse ( args [ 0 ] , out command ) )
187+ {
188+ Help ( ) ;
189+ return 1 ;
190+ }
191+ }
192+ }
193+ else if ( ! Command . TryParse ( args [ 0 ] , out command ) )
177194 {
178195 Help ( ) ;
179196 return 1 ;
@@ -430,7 +447,7 @@ struct Command
430447 }
431448
432449 static bool StartsWithHttp ( string s ) =>
433- s . Length > 4 && s [ 0 ] == 'h' && s [ 1 ] == 't' && s [ 2 ] == 't' && s [ 3 ] == 'p' ;
450+ s . Length > 6 && s [ 0 ] == 'h' && s [ 1 ] == 't' && s [ 2 ] == 't' && s [ 3 ] == 'p' && ( s [ 4 ] == ':' || ( s [ 4 ] == 's' && s [ 5 ] == ':' ) ) ;
434451
435452 static bool TryParseUri ( string s , out Uri uri )
436453 {
You can’t perform that action at this time.
0 commit comments