diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 67ffac46d6..6db24e8ef7 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -116,3 +116,10 @@ updates:
open-pull-requests-limit: 10
labels:
- TypeScript
+- package-ecosystem: nuget
+ directory: "/cli/commons"
+ schedule:
+ interval: daily
+ open-pull-requests-limit: 10
+ labels:
+ - CLI
diff --git a/.github/workflows/cli-commons.yml b/.github/workflows/cli-commons.yml
new file mode 100644
index 0000000000..99f5269d08
--- /dev/null
+++ b/.github/workflows/cli-commons.yml
@@ -0,0 +1,64 @@
+name: CLI commons
+
+on:
+ workflow_dispatch:
+ push:
+ branches: [ main ]
+ paths: ['cli/commons/**', '.github/workflows/**']
+ pull_request:
+ paths: ['cli/commons/**', '.github/workflows/**']
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ env:
+ relativePath: ./cli/commons
+ solutionName: Microsoft.Kiota.Cli.Commons.sln
+ steps:
+ - uses: actions/checkout@v2.4.0
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1.9.0
+ with:
+ dotnet-version: 6.0.x
+ - name: Restore dependencies
+ run: dotnet restore ${{ env.solutionName }}
+ working-directory: ${{ env.relativePath }}
+ - name: Build
+ run: dotnet build ${{ env.solutionName }} --no-restore -c Release
+ working-directory: ${{ env.relativePath }}
+ - name: Test
+ run: dotnet test ${{ env.solutionName }} --no-build --verbosity normal -c Release /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=opencover
+ working-directory: ${{ env.relativePath }}
+ - name: Publish
+ run: dotnet publish ${{ env.solutionName }} --no-restore --no-build --verbosity normal -c Release
+ working-directory: ${{ env.relativePath }}
+ - name: Pack
+ run: dotnet pack ${{ env.solutionName }} --no-restore --no-build --verbosity normal -c Release
+ working-directory: ${{ env.relativePath }}
+ - name: Upload Coverage Results
+ uses: actions/upload-artifact@v2
+ with:
+ name: codeCoverage
+ path: |
+ ${{ env.relativePath }}src/Microsoft.Kiota.Cli.Commons.Tests/TestResults
+ - name: Upload Nuget Package
+ uses: actions/upload-artifact@v2
+ with:
+ name: drop
+ path: |
+ ${{ env.relativePath }}/src/bin/Release/*.nupkg
+ deploy:
+ if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
+ environment:
+ name: staging_feeds
+ runs-on: ubuntu-latest
+ needs: [build]
+ steps:
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1.9.0
+ with:
+ dotnet-version: 6.0.x
+ - uses: actions/download-artifact@v2
+ with:
+ name: drop
+ - run: dotnet nuget push "*.nupkg" --skip-duplicate -s https://nuget.pkg.github.com/microsoft/index.json -k ${{ secrets.PUBLISH_GH_TOKEN }}
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index fc908e7e9e..927dbd2b35 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -15,10 +15,10 @@ on:
workflow_dispatch:
push:
branches: [ main ]
- path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
+ path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
pull_request:
# The branches below must be a subset of the branches above
- path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
+ path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
schedule:
- cron: '20 9 * * 5'
diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
index e7790b5fb2..5d95adc35b 100644
--- a/.github/workflows/sonarcloud.yml
+++ b/.github/workflows/sonarcloud.yml
@@ -4,10 +4,10 @@ on:
push:
branches:
- main
- path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
+ path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
pull_request:
types: [opened, synchronize, reopened]
- path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
+ path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
diff --git a/README.md b/README.md
index 8dce2ac4b6..a1c56e17f9 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ The following table provides an overview of the languages supported by Kiota and
| Python | [▶](https://github.com/microsoft/kiota/projects/3) | [✔](./abstractions/python) | ❌ | [Anonymous](./abstractions/python/kiota/abstractions/authentication/anonymous_authentication_provider.py), [Azure](./authentication/python/azure) | ❌ | |
| Ruby | [✔](https://github.com/microsoft/kiota/projects/6) | [✔](./abstractions/ruby) | [JSON](./serialization/ruby/json/microsoft_kiota_serialization) | [Anonymous](./abstractions/ruby/microsoft_kiota_abstractions/lib/microsoft_kiota_abstractions/authentication/anonymous_authentication_provider.rb), [❌ Azure](https://github.com/microsoft/kiota/issues/421) | [✔](./http/ruby/nethttp/microsoft_kiota_nethttplibrary)| [link](https://microsoft.github.io/kiota/get-started/ruby) |
| TypeScript/JavaScript | [✔](https://github.com/microsoft/kiota/projects/2) | [✔](./abstractions/typescript) | [JSON](./serialization/typescript/json) | [Anonymous](./abstractions/typescript/src/authentication/anonymousAuthenticationProvider.ts), [Azure](./authentication/typescript/azure) | [✔](./http/typescript/fetch) | [link](https://microsoft.github.io/kiota/get-started/typescript) |
+| Shell | [✔](https://github.com/microsoft/kiota/projects/10) | [✔](./abstractions/dotnet), [✔](./cli/commonc) | [JSON](./serialization/dotnet/json) | [Anonymous](./abstractions/dotnet/src/authentication/AnonymousAuthenticationProvider.cs), [Azure](./authentication/dotnet/azure) | [✔](./http/dotnet/httpclient) | [link](https://microsoft.github.io/kiota/get-started/dotnet) |
> Legend: ✔ -> in preview, ❌ -> not started, ▶ -> in progress.
diff --git a/cli/commons/Microsoft.Kiota.Cli.Commons.sln b/cli/commons/Microsoft.Kiota.Cli.Commons.sln
new file mode 100644
index 0000000000..1608855473
--- /dev/null
+++ b/cli/commons/Microsoft.Kiota.Cli.Commons.sln
@@ -0,0 +1,34 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30114.105
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8DEB9AF3-BEA6-4E73-BB5E-EBC1DFE6AF22}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Cli.Commons", "src\Microsoft.Kiota.Cli.Commons\Microsoft.Kiota.Cli.Commons.csproj", "{23DD14C5-3060-4498-B2F9-85B68770AE0B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Cli.Commons.Tests", "src\Microsoft.Kiota.Cli.Commons.Tests\Microsoft.Kiota.Cli.Commons.Tests.csproj", "{D1228DD9-C98F-46C1-911A-65AE2D34DBE5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {23DD14C5-3060-4498-B2F9-85B68770AE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {23DD14C5-3060-4498-B2F9-85B68770AE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {23DD14C5-3060-4498-B2F9-85B68770AE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {23DD14C5-3060-4498-B2F9-85B68770AE0B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {23DD14C5-3060-4498-B2F9-85B68770AE0B} = {8DEB9AF3-BEA6-4E73-BB5E-EBC1DFE6AF22}
+ {D1228DD9-C98F-46C1-911A-65AE2D34DBE5} = {8DEB9AF3-BEA6-4E73-BB5E-EBC1DFE6AF22}
+ EndGlobalSection
+EndGlobal
diff --git a/cli/commons/README.md b/cli/commons/README.md
new file mode 100644
index 0000000000..a2ee63c92a
--- /dev/null
+++ b/cli/commons/README.md
@@ -0,0 +1,3 @@
+# Kiota CLI Commons Package
+
+Contains CLI specific types that are referenced in code generated by the shell language.
\ No newline at end of file
diff --git a/cli/commons/src/Microsoft.Kiota.Cli.Commons.Tests/Microsoft.Kiota.Cli.Commons.Tests.csproj b/cli/commons/src/Microsoft.Kiota.Cli.Commons.Tests/Microsoft.Kiota.Cli.Commons.Tests.csproj
new file mode 100644
index 0000000000..5f88768850
--- /dev/null
+++ b/cli/commons/src/Microsoft.Kiota.Cli.Commons.Tests/Microsoft.Kiota.Cli.Commons.Tests.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net6.0
+ enable
+
+ false
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
diff --git a/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/FormatterType.cs b/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/FormatterType.cs
new file mode 100644
index 0000000000..96618b0a82
--- /dev/null
+++ b/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/FormatterType.cs
@@ -0,0 +1,8 @@
+namespace Microsoft.Kiota.Cli.Commons.IO;
+
+public enum FormatterType
+{
+ JSON,
+ TABLE,
+ NONE
+}
diff --git a/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatter.cs b/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatter.cs
new file mode 100644
index 0000000000..924b8a754a
--- /dev/null
+++ b/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatter.cs
@@ -0,0 +1,10 @@
+using System.CommandLine;
+
+namespace Microsoft.Kiota.Cli.Commons.IO;
+
+public interface IOutputFormatter
+{
+ void WriteOutput(string content, IConsole console);
+
+ void WriteOutput(Stream content, IConsole console);
+}
diff --git a/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatterFactory.cs b/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatterFactory.cs
new file mode 100644
index 0000000000..4d8026a99a
--- /dev/null
+++ b/cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatterFactory.cs
@@ -0,0 +1,6 @@
+namespace Microsoft.Kiota.Cli.Commons.IO;
+
+public interface IOutputFormatterFactory
+{
+ IOutputFormatter GetFormatter(FormatterType formatterType);
+}
diff --git a/cli/commons/src/Microsoft.Kiota.Cli.Commons/Microsoft.Kiota.Cli.Commons.csproj b/cli/commons/src/Microsoft.Kiota.Cli.Commons/Microsoft.Kiota.Cli.Commons.csproj
new file mode 100644
index 0000000000..062e460d3f
--- /dev/null
+++ b/cli/commons/src/Microsoft.Kiota.Cli.Commons/Microsoft.Kiota.Cli.Commons.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+ 0.1.0
+
+
+
+
+
+
+
diff --git a/src/Kiota.Builder/Refiners/ShellRefiner.cs b/src/Kiota.Builder/Refiners/ShellRefiner.cs
index a209bd19df..deb03b33b1 100644
--- a/src/Kiota.Builder/Refiners/ShellRefiner.cs
+++ b/src/Kiota.Builder/Refiners/ShellRefiner.cs
@@ -166,7 +166,7 @@ private static CodeMethod CreateBuildCommandMethod(CodeProperty navProperty, Cod
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder),
"System.CommandLine", "Command", "RootCommand"),
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder),
- "Microsoft.Graph.Cli.Core.IO", "IOutputFormatterFactory"),
+ "Microsoft.Kiota.Cli.Commons.IO", "IOutputFormatterFactory"),
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder),
"System.Text", "Encoding"),
};