@@ -31,20 +31,14 @@ public Command BuildDeleteCommand()
3131 {
3232 var command = new Command ( "delete" ) ;
3333 command . Description = "Delete post" ;
34- var postIdOption = new Option < int ? > ( "--post-id" , description : "key: id of post" ) {
35- } ;
36- postIdOption . IsRequired = true ;
37- command . AddOption ( postIdOption ) ;
3834 var outputFileOption = new Option < FileInfo > ( "--output-file" ) ;
3935 command . AddOption ( outputFileOption ) ;
4036 command . SetHandler ( async ( invocationContext ) => {
41- var postId = invocationContext . ParseResult . GetValueForOption ( postIdOption ) ;
4237 var outputFile = invocationContext . ParseResult . GetValueForOption ( outputFileOption ) ;
4338 var cancellationToken = invocationContext . GetCancellationToken ( ) ;
4439 var reqAdapter = invocationContext . GetRequestAdapter ( ) ;
4540 var requestInfo = ToDeleteRequestInformation ( q => {
4641 } ) ;
47- if ( postId is not null ) requestInfo . PathParameters . Add ( "post%2Did" , postId ) ;
4842 var response = await reqAdapter . SendPrimitiveAsync < Stream > ( requestInfo , errorMapping : default , cancellationToken : cancellationToken ) ?? Stream . Null ;
4943 if ( outputFile == null ) {
5044 using var reader = new StreamReader ( response ) ;
@@ -67,16 +61,11 @@ public Command BuildGetCommand()
6761 {
6862 var command = new Command ( "get" ) ;
6963 command . Description = "Get post by ID" ;
70- var postIdOption = new Option < int ? > ( "--post-id" , description : "key: id of post" ) {
71- } ;
72- postIdOption . IsRequired = true ;
73- command . AddOption ( postIdOption ) ;
7464 var outputOption = new Option < FormatterType > ( "--output" , ( ) => FormatterType . JSON ) ;
7565 command . AddOption ( outputOption ) ;
7666 var queryOption = new Option < string > ( "--query" ) ;
7767 command . AddOption ( queryOption ) ;
7868 command . SetHandler ( async ( invocationContext ) => {
79- var postId = invocationContext . ParseResult . GetValueForOption ( postIdOption ) ;
8069 var output = invocationContext . ParseResult . GetValueForOption ( outputOption ) ;
8170 var query = invocationContext . ParseResult . GetValueForOption ( queryOption ) ;
8271 IOutputFilter outputFilter = invocationContext . BindingContext . GetService ( typeof ( IOutputFilter ) ) as IOutputFilter ?? throw new ArgumentNullException ( "outputFilter" ) ;
@@ -85,7 +74,6 @@ public Command BuildGetCommand()
8574 var reqAdapter = invocationContext . GetRequestAdapter ( ) ;
8675 var requestInfo = ToGetRequestInformation ( q => {
8776 } ) ;
88- if ( postId is not null ) requestInfo . PathParameters . Add ( "post%2Did" , postId ) ;
8977 var response = await reqAdapter . SendPrimitiveAsync < Stream > ( requestInfo , errorMapping : default , cancellationToken : cancellationToken ) ?? Stream . Null ;
9078 response = ( response != Stream . Null ) ? await outputFilter . FilterOutputAsync ( response , query , cancellationToken ) : response ;
9179 var formatter = outputFormatterFactory . GetFormatter ( output ) ;
@@ -101,10 +89,6 @@ public Command BuildPatchCommand()
10189 {
10290 var command = new Command ( "patch" ) ;
10391 command . Description = "Update post" ;
104- var postIdOption = new Option < int ? > ( "--post-id" , description : "key: id of post" ) {
105- } ;
106- postIdOption . IsRequired = true ;
107- command . AddOption ( postIdOption ) ;
10892 var bodyOption = new Option < string > ( "--body" , description : "The request body" ) {
10993 } ;
11094 bodyOption . IsRequired = true ;
@@ -114,7 +98,6 @@ public Command BuildPatchCommand()
11498 var queryOption = new Option < string > ( "--query" ) ;
11599 command . AddOption ( queryOption ) ;
116100 command . SetHandler ( async ( invocationContext ) => {
117- var postId = invocationContext . ParseResult . GetValueForOption ( postIdOption ) ;
118101 var body = invocationContext . ParseResult . GetValueForOption ( bodyOption ) ?? string . Empty ;
119102 var output = invocationContext . ParseResult . GetValueForOption ( outputOption ) ;
120103 var query = invocationContext . ParseResult . GetValueForOption ( queryOption ) ;
@@ -131,7 +114,6 @@ public Command BuildPatchCommand()
131114 }
132115 var requestInfo = ToPatchRequestInformation ( model , q => {
133116 } ) ;
134- if ( postId is not null ) requestInfo . PathParameters . Add ( "post%2Did" , postId ) ;
135117 requestInfo . SetContentFromParsable ( reqAdapter , "application/json" , model ) ;
136118 var response = await reqAdapter . SendPrimitiveAsync < Stream > ( requestInfo , errorMapping : default , cancellationToken : cancellationToken ) ?? Stream . Null ;
137119 response = ( response != Stream . Null ) ? await outputFilter . FilterOutputAsync ( response , query , cancellationToken ) : response ;
0 commit comments