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

Commit daed1b1

Browse files
authored
Merge pull request #7 from microsoftgraph/feat/initialize_cli
Initialize CLI from generated code
2 parents 8cea3e4 + 491512f commit daed1b1

File tree

363 files changed

+32
-2824
lines changed

Some content is hidden

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

363 files changed

+32
-2824
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
"program": "${workspaceFolder}/src/bin/Debug/net6.0/msgraph-cli.dll",
13-
"args": [],
13+
"args": ["-h"],
1414
"cwd": "${workspaceFolder}",
1515
"console": "internalConsole",
1616
"stopAtEntry": false

src/Program.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
using System.CommandLine;
1+
using ApiSdk;
2+
using Azure.Identity;
3+
using Microsoft.Graph.Cli.Utils;
4+
using Microsoft.Kiota.Authentication.Azure;
5+
using Microsoft.Kiota.Http.HttpClientLibrary;
6+
using System.CommandLine;
27
using System.Threading.Tasks;
38

49
namespace Microsoft.Graph.Cli
510
{
611
class Program {
712
static async Task<int> Main(string[] args) {
8-
var rootCommand = new RootCommand(); // TODO: Replace with root command from generated client
13+
DeviceCodeCredentialOptions credOptions = new()
14+
{
15+
ClientId = Constants.ClientId,
16+
TenantId = Constants.TenantId
17+
};
18+
19+
var credential = new DeviceCodeCredential(credOptions);
20+
var authProvider = new AzureIdentityAuthenticationProvider(credential);
21+
var core = new HttpClientRequestAdapter(authProvider);
22+
var client = new GraphClient(core);
23+
24+
var rootCommand = client.BuildCommand();
925
rootCommand.Description = "Microsoft Graph CLI";
1026
return await rootCommand.InvokeAsync(args);
1127
}

src/generated/Admin/ServiceAnnouncement/HealthOverviews/Item/ServiceHealthRequestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ public Command BuildGetCommand() {
6666
public Command BuildIssuesCommand() {
6767
var command = new Command("issues");
6868
var builder = new ApiSdk.Admin.ServiceAnnouncement.HealthOverviews.Item.Issues.IssuesRequestBuilder(PathParameters, RequestAdapter);
69-
foreach (var cmd in builder.BuildCommand()) {
70-
command.AddCommand(cmd);
71-
}
7269
command.AddCommand(builder.BuildCreateCommand());
7370
command.AddCommand(builder.BuildListCommand());
7471
return command;

src/generated/Admin/ServiceAnnouncement/ServiceAnnouncementRequestBuilder.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,13 @@ public Command BuildGetCommand() {
6464
public Command BuildHealthOverviewsCommand() {
6565
var command = new Command("health-overviews");
6666
var builder = new ApiSdk.Admin.ServiceAnnouncement.HealthOverviews.HealthOverviewsRequestBuilder(PathParameters, RequestAdapter);
67-
foreach (var cmd in builder.BuildCommand()) {
68-
command.AddCommand(cmd);
69-
}
7067
command.AddCommand(builder.BuildCreateCommand());
7168
command.AddCommand(builder.BuildListCommand());
7269
return command;
7370
}
7471
public Command BuildIssuesCommand() {
7572
var command = new Command("issues");
7673
var builder = new ApiSdk.Admin.ServiceAnnouncement.Issues.IssuesRequestBuilder(PathParameters, RequestAdapter);
77-
foreach (var cmd in builder.BuildCommand()) {
78-
command.AddCommand(cmd);
79-
}
8074
command.AddCommand(builder.BuildCreateCommand());
8175
command.AddCommand(builder.BuildListCommand());
8276
return command;
@@ -85,9 +79,6 @@ public Command BuildMessagesCommand() {
8579
var command = new Command("messages");
8680
var builder = new ApiSdk.Admin.ServiceAnnouncement.Messages.MessagesRequestBuilder(PathParameters, RequestAdapter);
8781
command.AddCommand(builder.BuildArchiveCommand());
88-
foreach (var cmd in builder.BuildCommand()) {
89-
command.AddCommand(cmd);
90-
}
9182
command.AddCommand(builder.BuildCreateCommand());
9283
command.AddCommand(builder.BuildFavoriteCommand());
9384
command.AddCommand(builder.BuildListCommand());

src/generated/Agreements/Item/AgreementRequestBuilder.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ public class AgreementRequestBuilder {
2525
public Command BuildAcceptancesCommand() {
2626
var command = new Command("acceptances");
2727
var builder = new ApiSdk.Agreements.Item.Acceptances.AcceptancesRequestBuilder(PathParameters, RequestAdapter);
28-
foreach (var cmd in builder.BuildCommand()) {
29-
command.AddCommand(cmd);
30-
}
3128
command.AddCommand(builder.BuildCreateCommand());
3229
command.AddCommand(builder.BuildListCommand());
3330
return command;
@@ -61,9 +58,6 @@ public Command BuildFileCommand() {
6158
public Command BuildFilesCommand() {
6259
var command = new Command("files");
6360
var builder = new ApiSdk.Agreements.Item.Files.FilesRequestBuilder(PathParameters, RequestAdapter);
64-
foreach (var cmd in builder.BuildCommand()) {
65-
command.AddCommand(cmd);
66-
}
6761
command.AddCommand(builder.BuildCreateCommand());
6862
command.AddCommand(builder.BuildListCommand());
6963
return command;

src/generated/Agreements/Item/File/FileRequestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ public Command BuildGetCommand() {
6666
public Command BuildLocalizationsCommand() {
6767
var command = new Command("localizations");
6868
var builder = new ApiSdk.Agreements.Item.File.Localizations.LocalizationsRequestBuilder(PathParameters, RequestAdapter);
69-
foreach (var cmd in builder.BuildCommand()) {
70-
command.AddCommand(cmd);
71-
}
7269
command.AddCommand(builder.BuildCreateCommand());
7370
command.AddCommand(builder.BuildListCommand());
7471
return command;

src/generated/Agreements/Item/File/Localizations/Item/AgreementFileLocalizationRequestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ public Command BuildPatchCommand() {
9393
public Command BuildVersionsCommand() {
9494
var command = new Command("versions");
9595
var builder = new ApiSdk.Agreements.Item.File.Localizations.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter);
96-
foreach (var cmd in builder.BuildCommand()) {
97-
command.AddCommand(cmd);
98-
}
9996
command.AddCommand(builder.BuildCreateCommand());
10097
command.AddCommand(builder.BuildListCommand());
10198
return command;

src/generated/Agreements/Item/Files/Item/AgreementFileLocalizationRequestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ public Command BuildPatchCommand() {
9393
public Command BuildVersionsCommand() {
9494
var command = new Command("versions");
9595
var builder = new ApiSdk.Agreements.Item.Files.Item.Versions.VersionsRequestBuilder(PathParameters, RequestAdapter);
96-
foreach (var cmd in builder.BuildCommand()) {
97-
command.AddCommand(cmd);
98-
}
9996
command.AddCommand(builder.BuildCreateCommand());
10097
command.AddCommand(builder.BuildListCommand());
10198
return command;

src/generated/AppCatalogs/AppCatalogsRequestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ public Command BuildPatchCommand() {
6666
public Command BuildTeamsAppsCommand() {
6767
var command = new Command("teams-apps");
6868
var builder = new ApiSdk.AppCatalogs.TeamsApps.TeamsAppsRequestBuilder(PathParameters, RequestAdapter);
69-
foreach (var cmd in builder.BuildCommand()) {
70-
command.AddCommand(cmd);
71-
}
7269
command.AddCommand(builder.BuildCreateCommand());
7370
command.AddCommand(builder.BuildListCommand());
7471
return command;

src/generated/AppCatalogs/TeamsApps/Item/TeamsAppRequestBuilder.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ public class TeamsAppRequestBuilder {
2323
public Command BuildAppDefinitionsCommand() {
2424
var command = new Command("app-definitions");
2525
var builder = new ApiSdk.AppCatalogs.TeamsApps.Item.AppDefinitions.AppDefinitionsRequestBuilder(PathParameters, RequestAdapter);
26-
foreach (var cmd in builder.BuildCommand()) {
27-
command.AddCommand(cmd);
28-
}
2926
command.AddCommand(builder.BuildCreateCommand());
3027
command.AddCommand(builder.BuildListCommand());
3128
return command;

0 commit comments

Comments
 (0)