Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 113be24

Browse files
authored
Merge pull request #13 from microsoftgraph/chore/update_system_commandline
Chore/update system commandline
2 parents 8ef50d0 + 866e44d commit 113be24

File tree

5,799 files changed

+115288
-76539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,799 files changed

+115288
-76539
lines changed

src/Commands/Authentication/LoginCommand.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/Commands/Authentication/LogoutCommand.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Configuration/AuthenticationOptions.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/Program.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Hosting;
66
using Microsoft.Graph.Cli.Core.Authentication;
7-
using Microsoft.Graph.Cli.Commands.Authentication;
8-
using Microsoft.Graph.Cli.Configuration;
7+
using Microsoft.Graph.Cli.Core.Commands.Authentication;
8+
using Microsoft.Graph.Cli.Core.Configuration;
99
using Microsoft.Graph.Cli.Core.IO;
1010
using Microsoft.Graph.Cli.Core.Utils;
1111
using Microsoft.Kiota.Authentication.Azure;
@@ -21,6 +21,7 @@
2121
using System.Net.Http;
2222
using System.Reflection;
2323
using System.Threading.Tasks;
24+
using System.Collections.Generic;
2425

2526
namespace Microsoft.Graph.Cli
2627
{
@@ -65,24 +66,32 @@ static async Task<int> Main(string[] args)
6566
using var httpClient = KiotaClientFactory.Create(finalHandler);
6667
var core = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
6768
var client = new GraphClient(core);
68-
var builder = BuildCommandLine(client);
69+
var rootCommand = client.BuildCommand();
70+
rootCommand.Description = "Microsoft Graph CLI";
6971

72+
var commands = new List<Command>();
7073
var loginCommand = new LoginCommand(authServiceFactory);
71-
builder.AddCommand(loginCommand.Build());
74+
commands.Add(loginCommand.Build());
7275

7376
var logoutCommand = new LogoutCommand(new LogoutService());
74-
builder.AddCommand(logoutCommand.Build());
77+
commands.Add(logoutCommand.Build());
78+
79+
var builder = BuildCommandLine(client, commands);
7580

7681
var parser = builder.UseHost(CreateHostBuilder).UseDefaults().Build();
7782

7883
return await parser.InvokeAsync(args);
7984
}
8085

81-
static CommandLineBuilder BuildCommandLine(GraphClient client)
86+
static CommandLineBuilder BuildCommandLine(GraphClient client, IEnumerable<Command> commands)
8287
{
8388
var rootCommand = client.BuildCommand();
8489
rootCommand.Description = "Microsoft Graph CLI";
8590

91+
foreach (var command in commands) {
92+
rootCommand.AddCommand(command);
93+
}
94+
8695
return new CommandLineBuilder(rootCommand);
8796
}
8897

src/generated/Admin/AdminRequestBuilder.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ public Command BuildGetCommand() {
2727
var command = new Command("get");
2828
command.Description = "Get admin";
2929
// Create options for all the parameters
30-
var selectOption = new Option<string[]>("--select", description: "Select properties to be returned");
30+
var selectOption = new Option<string[]>("--select", description: "Select properties to be returned") {
31+
Arity = ArgumentArity.ZeroOrMore
32+
};
3133
selectOption.IsRequired = false;
32-
selectOption.Arity = ArgumentArity.ZeroOrMore;
3334
command.AddOption(selectOption);
34-
var expandOption = new Option<string[]>("--expand", description: "Expand related entities");
35+
var expandOption = new Option<string[]>("--expand", description: "Expand related entities") {
36+
Arity = ArgumentArity.ZeroOrMore
37+
};
3538
expandOption.IsRequired = false;
36-
expandOption.Arity = ArgumentArity.ZeroOrMore;
3739
command.AddOption(expandOption);
38-
command.Handler = CommandHandler.Create<string[], string[]>(async (select, expand) => {
40+
command.SetHandler(async (string[] select, string[] expand) => {
3941
var requestInfo = CreateGetRequestInformation(q => {
4042
q.Select = select;
4143
q.Expand = expand;
@@ -48,7 +50,7 @@ public Command BuildGetCommand() {
4850
using var reader = new StreamReader(content);
4951
var strContent = await reader.ReadToEndAsync();
5052
Console.Write(strContent + "\n");
51-
});
53+
}, selectOption, expandOption);
5254
return command;
5355
}
5456
/// <summary>
@@ -58,10 +60,11 @@ public Command BuildPatchCommand() {
5860
var command = new Command("patch");
5961
command.Description = "Update admin";
6062
// Create options for all the parameters
61-
var bodyOption = new Option<string>("--body");
63+
var bodyOption = new Option<string>("--body") {
64+
};
6265
bodyOption.IsRequired = true;
6366
command.AddOption(bodyOption);
64-
command.Handler = CommandHandler.Create<string>(async (body) => {
67+
command.SetHandler(async (string body) => {
6568
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
6669
var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
6770
var model = parseNode.GetObjectValue<ApiSdk.Models.Microsoft.Graph.Admin>();
@@ -70,7 +73,7 @@ public Command BuildPatchCommand() {
7073
await RequestAdapter.SendNoContentAsync(requestInfo);
7174
// Print request output. What if the request has no return?
7275
Console.WriteLine("Success");
73-
});
76+
}, bodyOption);
7477
return command;
7578
}
7679
public Command BuildServiceAnnouncementCommand() {
@@ -105,7 +108,7 @@ public AdminRequestBuilder(Dictionary<string, object> pathParameters, IRequestAd
105108
/// </summary>
106109
public RequestInformation CreateGetRequestInformation(Action<GetQueryParameters> q = default, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default) {
107110
var requestInfo = new RequestInformation {
108-
HttpMethod = HttpMethod.GET,
111+
HttpMethod = Method.GET,
109112
UrlTemplate = UrlTemplate,
110113
PathParameters = PathParameters,
111114
};
@@ -127,7 +130,7 @@ public RequestInformation CreateGetRequestInformation(Action<GetQueryParameters>
127130
public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Admin body, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default) {
128131
_ = body ?? throw new ArgumentNullException(nameof(body));
129132
var requestInfo = new RequestInformation {
130-
HttpMethod = HttpMethod.PATCH,
133+
HttpMethod = Method.PATCH,
131134
UrlTemplate = UrlTemplate,
132135
PathParameters = PathParameters,
133136
};

src/generated/Admin/ServiceAnnouncement/HealthOverviews/HealthOverviewsRequestBuilder.cs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ public Command BuildCreateCommand() {
3737
var command = new Command("create");
3838
command.Description = "A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.";
3939
// Create options for all the parameters
40-
var bodyOption = new Option<string>("--body");
40+
var bodyOption = new Option<string>("--body") {
41+
};
4142
bodyOption.IsRequired = true;
4243
command.AddOption(bodyOption);
43-
command.Handler = CommandHandler.Create<string>(async (body) => {
44+
command.SetHandler(async (string body) => {
4445
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
4546
var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
4647
var model = parseNode.GetObjectValue<ServiceHealth>();
@@ -54,7 +55,7 @@ public Command BuildCreateCommand() {
5455
using var reader = new StreamReader(content);
5556
var strContent = await reader.ReadToEndAsync();
5657
Console.Write(strContent + "\n");
57-
});
58+
}, bodyOption);
5859
return command;
5960
}
6061
/// <summary>
@@ -64,34 +65,42 @@ public Command BuildListCommand() {
6465
var command = new Command("list");
6566
command.Description = "A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.";
6667
// Create options for all the parameters
67-
var topOption = new Option<int?>("--top", description: "Show only the first n items");
68+
var topOption = new Option<int?>("--top", description: "Show only the first n items") {
69+
};
6870
topOption.IsRequired = false;
6971
command.AddOption(topOption);
70-
var skipOption = new Option<int?>("--skip", description: "Skip the first n items");
72+
var skipOption = new Option<int?>("--skip", description: "Skip the first n items") {
73+
};
7174
skipOption.IsRequired = false;
7275
command.AddOption(skipOption);
73-
var searchOption = new Option<string>("--search", description: "Search items by search phrases");
76+
var searchOption = new Option<string>("--search", description: "Search items by search phrases") {
77+
};
7478
searchOption.IsRequired = false;
7579
command.AddOption(searchOption);
76-
var filterOption = new Option<string>("--filter", description: "Filter items by property values");
80+
var filterOption = new Option<string>("--filter", description: "Filter items by property values") {
81+
};
7782
filterOption.IsRequired = false;
7883
command.AddOption(filterOption);
79-
var countOption = new Option<bool?>("--count", description: "Include count of items");
84+
var countOption = new Option<bool?>("--count", description: "Include count of items") {
85+
};
8086
countOption.IsRequired = false;
8187
command.AddOption(countOption);
82-
var orderbyOption = new Option<string[]>("--orderby", description: "Order items by property values");
88+
var orderbyOption = new Option<string[]>("--orderby", description: "Order items by property values") {
89+
Arity = ArgumentArity.ZeroOrMore
90+
};
8391
orderbyOption.IsRequired = false;
84-
orderbyOption.Arity = ArgumentArity.ZeroOrMore;
8592
command.AddOption(orderbyOption);
86-
var selectOption = new Option<string[]>("--select", description: "Select properties to be returned");
93+
var selectOption = new Option<string[]>("--select", description: "Select properties to be returned") {
94+
Arity = ArgumentArity.ZeroOrMore
95+
};
8796
selectOption.IsRequired = false;
88-
selectOption.Arity = ArgumentArity.ZeroOrMore;
8997
command.AddOption(selectOption);
90-
var expandOption = new Option<string[]>("--expand", description: "Expand related entities");
98+
var expandOption = new Option<string[]>("--expand", description: "Expand related entities") {
99+
Arity = ArgumentArity.ZeroOrMore
100+
};
91101
expandOption.IsRequired = false;
92-
expandOption.Arity = ArgumentArity.ZeroOrMore;
93102
command.AddOption(expandOption);
94-
command.Handler = CommandHandler.Create<int?, int?, string, string, bool?, string[], string[], string[]>(async (top, skip, search, filter, count, orderby, select, expand) => {
103+
command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => {
95104
var requestInfo = CreateGetRequestInformation(q => {
96105
q.Top = top;
97106
q.Skip = skip;
@@ -110,7 +119,7 @@ public Command BuildListCommand() {
110119
using var reader = new StreamReader(content);
111120
var strContent = await reader.ReadToEndAsync();
112121
Console.Write(strContent + "\n");
113-
});
122+
}, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption);
114123
return command;
115124
}
116125
/// <summary>
@@ -134,7 +143,7 @@ public HealthOverviewsRequestBuilder(Dictionary<string, object> pathParameters,
134143
/// </summary>
135144
public RequestInformation CreateGetRequestInformation(Action<GetQueryParameters> q = default, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default) {
136145
var requestInfo = new RequestInformation {
137-
HttpMethod = HttpMethod.GET,
146+
HttpMethod = Method.GET,
138147
UrlTemplate = UrlTemplate,
139148
PathParameters = PathParameters,
140149
};
@@ -156,7 +165,7 @@ public RequestInformation CreateGetRequestInformation(Action<GetQueryParameters>
156165
public RequestInformation CreatePostRequestInformation(ServiceHealth body, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default) {
157166
_ = body ?? throw new ArgumentNullException(nameof(body));
158167
var requestInfo = new RequestInformation {
159-
HttpMethod = HttpMethod.POST,
168+
HttpMethod = Method.POST,
160169
UrlTemplate = UrlTemplate,
161170
PathParameters = PathParameters,
162171
};

0 commit comments

Comments
 (0)