Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename shell to CLI #3087

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"--openapi",
"https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/dev/openApiDocs/v1.0/Mail.yml",
"--language",
"shell",
"cli",
"-o",
"${workspaceFolder}/samples/msgraph-mail/dotnet-cli",
"--clean-output"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Renamed the Shell language to CLI. [#3023](https://github.com/microsoft/kiota/issues/3023)

## [1.5.0] - 2023-08-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The following table provides an overview of the languages supported by Kiota and
| PHP | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-php) | [JSON](https://github.com/microsoft/kiota-serialization-json-php), [❌ FORM](https://github.com/microsoft/kiota/issues/2074), [❌ MULTIPART](https://github.com/microsoft/kiota/issues/3029), [TEXT](https://github.com/microsoft/kiota-serialization-text-php) | [Anonymous](https://github.com/microsoft/kiota-abstractions-php/blob/main/src/Authentication/AnonymousAuthenticationProvider.php), [✔️ PHP League](https://github.com/microsoft/kiota-authentication-phpleague-php) | [✔](https://github.com/microsoft/kiota-http-guzzle-php) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/php) |
| Python | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-python) | [❌ FORM](https://github.com/microsoft/kiota/issues/2075), [JSON](https://github.com/microsoft/kiota-serialization-json-python), [❌ MULTIPART](https://github.com/microsoft/kiota/issues/3030), [TEXT](https://github.com/microsoft/kiota-serialization-text-python) | [Anonymous](https://github.com/microsoft/kiota-abstractions-python/blob/main/kiota_abstractions/authentication/anonymous_authentication_provider.py), [Azure](https://github.com/microsoft/kiota-authentication-azure-python) | [✔](https://github.com/microsoft/kiota-http-python) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/python) |
| Ruby | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-ruby) | [❌ FORM](https://github.com/microsoft/kiota/issues/2077), [JSON](https://github.com/microsoft/kiota-serialization-json-ruby), [❌ MULTIPART](https://github.com/microsoft/kiota/issues/3032), [❌ TEXT](https://github.com/microsoft/kiota/issues/1049) | [Anonymous](https://github.com/microsoft/kiota-abstractions-ruby/blob/main/lib/microsoft_kiota_abstractions/authentication/anonymous_authentication_provider.rb), [✔️ OAuth2](https://github.com/microsoft/kiota-authentication-oauth-ruby) | [✔](https://github.com/microsoft/kiota-http-ruby)| [link](https://learn.microsoft.com/openapi/kiota/quickstarts/ruby) |
| Shell | ✔ | (see CSHarp) + [✔](https://github.com/microsoft/kiota-cli-commons) | (see CSHarp) | (see CSharp) | (see CSharp) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/cli) |
| CLI | ✔ | (see CSharp) + [✔](https://github.com/microsoft/kiota-cli-commons) | (see CSharp) | (see CSharp) | (see CSharp) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/cli) |
| Swift | [▶](https://github.com/microsoft/kiota/issues/1449) | [✔](./abstractions/swift) | [❌ FORM](https://github.com/microsoft/kiota/issues/2076), [❌ JSON](https://github.com/microsoft/kiota/issues/1451), [❌ FORM](https://github.com/microsoft/kiota/issues/3033), [❌ TEXT](https://github.com/microsoft/kiota/issues/1452) | [Anonymous](./abstractions/swift/Source/MicrosoftKiotaAbstractions/Authentication/AnonymousAuthenticationProvider.swift), [❌ Azure](https://github.com/microsoft/kiota/issues/1453) | [❌](https://github.com/microsoft/kiota/issues/1454)| |
| TypeScript/JavaScript | ✔ | [✔](https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions) | [FORM](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/form), [JSON](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/json), [MULTIPART](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/multipart), [TEXT](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/text) | [Anonymous](https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/authentication/anonymousAuthenticationProvider.ts), [API Key](https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/authentication/apiKeyAuthenticationProvider.ts), [Azure](https://github.com/microsoft/kiota-typescript/tree/main/packages/authentication/azure) | [✔](https://github.com/microsoft/kiota-typescript/tree/main/packages/http/fetch) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/typescript) |

Expand Down
2 changes: 1 addition & 1 deletion scripts/update-versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ $appSettings = Get-Content -Path $mainSettings -Raw | ConvertFrom-Json

foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name | Sort-Object)) {
$language = $appSettings.Languages.$languageName
if ($languageName -eq "CSharp" -or $languageName -eq "Shell") {
if ($languageName -eq "CSharp" -or $languageName -eq "CLI") {
foreach ($dependency in $language.Dependencies) {
Retry-Command -ScriptBlock {
$latestVersion = Get-LatestNugetVersion -packageId $dependency.Name
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/CodeDOM/CodeMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public PagingInformation? PagingInformation

/// <summary>
/// The combination of the path, query and header parameters for the current URL.
/// Only use this property if the language you are generating for doesn't support fluent API style (e.g. Shell/CLI)
/// Only use this property if the language you are generating for doesn't support fluent API style (e.g. CLI)
/// </summary>
public IEnumerable<CodeParameter> PathQueryAndHeaderParameters
{
Expand Down
26 changes: 13 additions & 13 deletions src/Kiota.Builder/GenerationLanguage.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace Kiota.Builder;
public enum GenerationLanguage
{
CSharp,
Java,
TypeScript,
PHP,
Python,
Go,
Swift,
Ruby,
Shell
}
namespace Kiota.Builder;
public enum GenerationLanguage
{
CSharp,
Java,
TypeScript,
PHP,
Python,
Go,
Swift,
Ruby,
CLI
}
2 changes: 1 addition & 1 deletion src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@

if (!"string".Equals(parameter.Type.Name, StringComparison.OrdinalIgnoreCase))
{ // adding a second indexer for the string version of the parameter so we keep backward compatibility
//TODO remove for v2

Check warning on line 1020 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment.
var backCompatibleValue = (CodeIndexer)result[0].Clone();
backCompatibleValue.Name += "-string";
backCompatibleValue.IndexParameter.Type = DefaultIndexerParameterType;
Expand Down Expand Up @@ -1263,7 +1263,7 @@
var mediaType = operation.Responses.Values.SelectMany(static x => x.Content).First(x => x.Value.Schema == schema).Key;
generatorMethod.AcceptedResponseTypes.Add(mediaType);
}
if (config.Language == GenerationLanguage.Shell)
if (config.Language == GenerationLanguage.CLI)
SetPathAndQueryParameters(generatorMethod, currentNode, operation);
AddRequestBuilderMethodParameters(currentNode, operationType, operation, requestConfigClass, generatorMethod);
parentClass.AddMethod(generatorMethod);
Expand Down Expand Up @@ -1639,7 +1639,7 @@
var schemaDescription = schema.Description.CleanupDescription();
var newEnum = new CodeEnum
{
Name = declarationName,//TODO set the flag property

Check warning on line 1642 in src/Kiota.Builder/KiotaBuilder.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment.
Documentation = new()
{
Description = !string.IsNullOrEmpty(schemaDescription) || !string.IsNullOrEmpty(schema.Reference?.Id) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
using Kiota.Builder.Extensions;

namespace Kiota.Builder.Refiners;
public class ShellRefiner : CSharpRefiner, ILanguageRefiner
public class CliRefiner : CSharpRefiner, ILanguageRefiner
{
private static readonly CodePropertyKind[] UnusedPropKinds = new[] { CodePropertyKind.RequestAdapter };
private static readonly CodeParameterKind[] UnusedParamKinds = new[] { CodeParameterKind.RequestAdapter };
private static readonly CodeMethodKind[] ConstructorKinds = new[] { CodeMethodKind.Constructor, CodeMethodKind.ClientConstructor, CodeMethodKind.RawUrlConstructor };
public ShellRefiner(GenerationConfiguration configuration) : base(configuration) { }
public CliRefiner(GenerationConfiguration configuration) : base(configuration) { }
public override Task Refine(CodeNamespace generatedCode, CancellationToken cancellationToken)
{
return Task.Run(() =>
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Refiners/ILanguageRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public static async Task Refine(GenerationConfiguration config, CodeNamespace ge
case GenerationLanguage.Go:
await new GoRefiner(config).Refine(generatedCode, cancellationToken).ConfigureAwait(false);
break;
case GenerationLanguage.Shell:
await new ShellRefiner(config).Refine(generatedCode, cancellationToken).ConfigureAwait(false);
case GenerationLanguage.CLI:
await new CliRefiner(config).Refine(generatedCode, cancellationToken).ConfigureAwait(false);
break;
case GenerationLanguage.Swift:
await new SwiftRefiner(config).Refine(generatedCode, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
using Kiota.Builder.Extensions;
using Kiota.Builder.Writers.CSharp;

namespace Kiota.Builder.Writers.Shell;
partial class ShellCodeMethodWriter : CodeMethodWriter
namespace Kiota.Builder.Writers.Cli;
partial class CliCodeMethodWriter : CodeMethodWriter
{
private static readonly Regex delimitedRegex = ShellDelimitedRegex();
private static readonly Regex camelCaseRegex = ShellCamelCaseRegex();
private static readonly Regex uppercaseRegex = ShellUppercaseRegex();
private static readonly Regex delimitedRegex = CliDelimitedRegex();
private static readonly Regex camelCaseRegex = CliCamelCaseRegex();
private static readonly Regex uppercaseRegex = CliUppercaseRegex();
private const string AllParamType = "bool";
private const string AllParamName = "all";
private const string CancellationTokenParamType = "CancellationToken";
Expand Down Expand Up @@ -43,7 +43,7 @@ partial class ShellCodeMethodWriter : CodeMethodWriter
private const string NonExecCommandsVariableName = "nonExecCommands";
private const string indexerReturn = "Tuple";

public ShellCodeMethodWriter(CSharpConventionService conventionService) : base(conventionService, true)
public CliCodeMethodWriter(CSharpConventionService conventionService) : base(conventionService, true)
{
}

Expand Down Expand Up @@ -890,9 +890,9 @@ private static string NormalizeToOption(string input)
}

[GeneratedRegex("(?<=[a-z])[-_\\.]+([A-Za-z])", RegexOptions.Compiled)]
private static partial Regex ShellDelimitedRegex();
private static partial Regex CliDelimitedRegex();
[GeneratedRegex("(?<=[a-z])([A-Z])", RegexOptions.Compiled)]
private static partial Regex ShellCamelCaseRegex();
private static partial Regex CliCamelCaseRegex();
[GeneratedRegex("([A-Z])", RegexOptions.Compiled)]
private static partial Regex ShellUppercaseRegex();
private static partial Regex CliUppercaseRegex();
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Kiota.Builder.Writers.CSharp;

namespace Kiota.Builder.Writers.Shell;
class ShellWriter : CSharpWriter
{
public ShellWriter(string rootPath, string clientNamespaceName) : base(rootPath, clientNamespaceName)
{
var conventionService = new CSharpConventionService();
AddOrReplaceCodeElementWriter(new CodeClassDeclarationWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeBlockEndWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeEnumWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeIndexerWriter(conventionService));
AddOrReplaceCodeElementWriter(new ShellCodeMethodWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodePropertyWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeTypeWriter(conventionService));
}
}
using Kiota.Builder.Writers.CSharp;
namespace Kiota.Builder.Writers.Cli;
class CliWriter : CSharpWriter
{
public CliWriter(string rootPath, string clientNamespaceName) : base(rootPath, clientNamespaceName)
{
var conventionService = new CSharpConventionService();
AddOrReplaceCodeElementWriter(new CodeClassDeclarationWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeBlockEndWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeEnumWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeIndexerWriter(conventionService));
AddOrReplaceCodeElementWriter(new CliCodeMethodWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodePropertyWriter(conventionService));
AddOrReplaceCodeElementWriter(new CodeTypeWriter(conventionService));
}
}
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Writers/LanguageWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

using Kiota.Builder.CodeDOM;
using Kiota.Builder.PathSegmenters;
using Kiota.Builder.Writers.Cli;
using Kiota.Builder.Writers.CSharp;
using Kiota.Builder.Writers.Go;
using Kiota.Builder.Writers.Java;
using Kiota.Builder.Writers.Php;
using Kiota.Builder.Writers.Python;
using Kiota.Builder.Writers.Ruby;
using Kiota.Builder.Writers.Shell;
using Kiota.Builder.Writers.Swift;
using Kiota.Builder.Writers.TypeScript;

Expand Down Expand Up @@ -181,7 +181,7 @@ public static LanguageWriter GetLanguageWriter(GenerationLanguage language, stri
GenerationLanguage.PHP => new PhpWriter(outputPath, clientNamespaceName, usesBackingStore),
GenerationLanguage.Python => new PythonWriter(outputPath, clientNamespaceName, usesBackingStore),
GenerationLanguage.Go => new GoWriter(outputPath, clientNamespaceName),
GenerationLanguage.Shell => new ShellWriter(outputPath, clientNamespaceName),
GenerationLanguage.CLI => new CliWriter(outputPath, clientNamespaceName),
GenerationLanguage.Swift => new SwiftWriter(outputPath, clientNamespaceName),
_ => throw new InvalidEnumArgumentException($"{language} language currently not supported."),
};
Expand Down
4 changes: 2 additions & 2 deletions src/kiota/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
"Dependencies": [],
"DependencyInstallCommand": ""
},
"Shell": {
"CLI": {
"MaturityLevel": "Preview",
"Dependencies": [
{
Expand Down Expand Up @@ -272,4 +272,4 @@
"DependencyInstallCommand": "dotnet add package {0} --version {1}"
}
}
}
}
4 changes: 2 additions & 2 deletions tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ public void Supports_Path_Query_And_Header_Parameters()
}
};
var mockLogger = new Mock<ILogger<KiotaBuilder>>();
var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", ApiRootUrl = "https://localhost", Language = GenerationLanguage.Shell }, _httpClient);
var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", ApiRootUrl = "https://localhost", Language = GenerationLanguage.CLI }, _httpClient);
var node = builder.CreateUriSpace(document);
var codeModel = builder.CreateSourceModel(node);
var deviceManagementNS = codeModel.FindNamespaceByName("ApiSdk.deviceManagement");
Expand Down Expand Up @@ -1331,7 +1331,7 @@ public void DeduplicatesConflictingParameterNamesForCLI()
},
};
var mockLogger = new Mock<ILogger<KiotaBuilder>>();
var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", ApiRootUrl = "https://localhost", Language = GenerationLanguage.Shell }, _httpClient);
var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", ApiRootUrl = "https://localhost", Language = GenerationLanguage.CLI }, _httpClient);
var node = builder.CreateUriSpace(document);
var codeModel = builder.CreateSourceModel(node);
var resultsNS = codeModel.FindNamespaceByName("ApiSdk.test.item.results");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Kiota.Builder.Tests.Refiners;

public class ShellRefinerTests
public class CliRefinerTests
{
private readonly CodeNamespace root = CodeNamespace.InitRootNamespace();

Expand Down Expand Up @@ -71,7 +71,7 @@ public async Task AddsUsingsForCommandTypesUsedInCommandBuilder()
IsExternal = true
}
}).First();
await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Shell }, root);
await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CLI }, root);

var declaration = requestBuilder.StartBlock;

Expand Down Expand Up @@ -166,7 +166,7 @@ public async Task CreatesCommandBuilders()
SerializerModules = new() { "com.microsoft.kiota.serialization.Serializer" }
});

await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Shell }, root);
await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CLI }, root);

var methods = root.GetChildElements().OfType<CodeClass>().SelectMany(c => c.Methods);
var methodNames = methods.Select(m => m.Name);
Expand Down Expand Up @@ -239,7 +239,7 @@ public async Task RemovesRequestAdaptersFromCodeDom()
Assert.Contains("adapter", propertyNames);
Assert.Contains("adapter", methodParamNames);

await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Shell }, root);
await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CLI }, root);

Assert.DoesNotContain("adapter", propertyNames);
Assert.DoesNotContain("adapter", methodParamNames);
Expand Down Expand Up @@ -285,7 +285,7 @@ public async Task RenamesNavPropertiesInIndexersWithConflicts()
};
rootRequestBuilder.AddIndexer(indexer);

await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Shell }, root);
await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CLI }, root);

Assert.Equal("GraphOrgContactNav-ById", idxNavProp.Name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

using Xunit;

namespace Kiota.Builder.Tests.Writers.Shell;
namespace Kiota.Builder.Tests.Writers.Cli;

public class ShellCodeMethodWriterTests : IDisposable
public class CliCodeMethodWriterTests : IDisposable
{
private const string DefaultPath = "./";
private const string DefaultName = "name";
Expand All @@ -22,9 +22,9 @@ public class ShellCodeMethodWriterTests : IDisposable
private const string MethodName = "methodName";
private const string ReturnTypeName = "Somecustomtype";

public ShellCodeMethodWriterTests()
public CliCodeMethodWriterTests()
{
writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.Shell, DefaultPath, DefaultName);
writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.CLI, DefaultPath, DefaultName);
tw = new StringWriter();
writer.SetTextWriter(tw);
root = CodeNamespace.InitRootNamespace();
Expand Down
12 changes: 6 additions & 6 deletions vscode/microsoft-kiota/src/kiotaInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export enum KiotaGenerationLanguage {
// eslint-disable-next-line @typescript-eslint/naming-convention
Ruby = 7,
// eslint-disable-next-line @typescript-eslint/naming-convention
Shell = 8,
CLI = 8,
}
export function generationLanguageToString(language: KiotaGenerationLanguage): string {
switch (language) {
Expand All @@ -106,8 +106,8 @@ export function generationLanguageToString(language: KiotaGenerationLanguage): s
return "Swift";
case KiotaGenerationLanguage.Ruby:
return "Ruby";
case KiotaGenerationLanguage.Shell:
return "Shell";
case KiotaGenerationLanguage.CLI:
return "CLI";
default:
throw new Error("unknown language");
}
Expand All @@ -130,8 +130,8 @@ export function parseGenerationLanguage(value: string): KiotaGenerationLanguage
return KiotaGenerationLanguage.Swift;
case "Ruby":
return KiotaGenerationLanguage.Ruby;
case "Shell":
return KiotaGenerationLanguage.Shell;
case "CLI":
return KiotaGenerationLanguage.CLI;
default:
throw new Error("unknown language");
}
Expand All @@ -143,7 +143,7 @@ export const allGenerationLanguages = [
KiotaGenerationLanguage.PHP,
KiotaGenerationLanguage.Python,
KiotaGenerationLanguage.Ruby,
KiotaGenerationLanguage.Shell,
KiotaGenerationLanguage.CLI,
KiotaGenerationLanguage.Swift,
KiotaGenerationLanguage.TypeScript,
];
Expand Down
Loading