From c22c5473e1e18de7419c9e61f75cfe52dd885a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C4=B0rgin?= Date: Thu, 30 Apr 2020 22:05:53 +0300 Subject: [PATCH] fix command line argument issue for json arguments add .netcore2.1 support --- .vscode/launch.json | 34 +++++++++++++++ .vscode/tasks.json | 42 +++++++++++++++++++ build/azure-pipelines.artifact.yml | 6 +++ build/azure-pipelines.macos.yml | 6 +++ build/azure-pipelines.ubuntu.yml | 6 +++ .../LocalStack.AwsLocal.csproj | 12 +++++- src/LocalStack.AwsLocal/Program.cs | 10 ++++- .../LocalStack.AwsLocal.Tests.csproj | 2 +- 8 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4674ce3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,34 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/src/LocalStack.AwsLocal/bin/Debug/netcoreapp3.1/LocalStack.AwsLocal.dll", + "args": [ + "sns", + "publish", + "--topic-arn", + "arn:aws:sns:eu-central-1:000000000000:sentinel-live-jobupdate", + "--message", + " '{ \"JobId\": 5, \"JobStatusId\" : 9, \"Environment\": \"Development\" }'" + ], + "cwd": "${workspaceFolder}/src/LocalStack.AwsLocal", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1e7b1fe --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/build/azure-pipelines.artifact.yml b/build/azure-pipelines.artifact.yml index 7a0a217..bacb182 100644 --- a/build/azure-pipelines.artifact.yml +++ b/build/azure-pipelines.artifact.yml @@ -25,6 +25,12 @@ steps: version: "3.1.x" packageType: sdk + - task: UseDotNet@2 + displayName: ".NET Core 2.1.x" + inputs: + version: "2.1.x" + packageType: sdk + - task: Bash@3 displayName: "Compile & Tests" inputs: diff --git a/build/azure-pipelines.macos.yml b/build/azure-pipelines.macos.yml index d0e4dba..9211786 100644 --- a/build/azure-pipelines.macos.yml +++ b/build/azure-pipelines.macos.yml @@ -27,6 +27,12 @@ steps: version: "3.1.x" packageType: sdk + - task: UseDotNet@2 + displayName: ".NET Core 2.1.x" + inputs: + version: "2.1.x" + packageType: sdk + - task: Bash@3 displayName: "Compile & Tests" inputs: diff --git a/build/azure-pipelines.ubuntu.yml b/build/azure-pipelines.ubuntu.yml index 76c5e4a..15e04f7 100644 --- a/build/azure-pipelines.ubuntu.yml +++ b/build/azure-pipelines.ubuntu.yml @@ -30,6 +30,12 @@ steps: version: "3.1.x" packageType: sdk + - task: UseDotNet@2 + displayName: ".NET Core 2.1.x" + inputs: + version: "2.1.x" + packageType: sdk + - task: Bash@3 displayName: "Compile & Tests" inputs: diff --git a/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj b/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj index a325c13..e4e622e 100644 --- a/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj +++ b/src/LocalStack.AwsLocal/LocalStack.AwsLocal.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + netcoreapp3.1;netcoreapp2.1 true LocalStack.AwsLocal LocalStack.AwsLocal @@ -29,7 +29,7 @@ Always - + @@ -46,4 +46,12 @@ + + + + + + + + \ No newline at end of file diff --git a/src/LocalStack.AwsLocal/Program.cs b/src/LocalStack.AwsLocal/Program.cs index 92d1ee8..c589301 100644 --- a/src/LocalStack.AwsLocal/Program.cs +++ b/src/LocalStack.AwsLocal/Program.cs @@ -1,5 +1,9 @@ using LocalStack.Client; using System; +using System.CommandLine; +using System.CommandLine.Parsing; +using System.Diagnostics; +using System.Linq; namespace LocalStack.AwsLocal { @@ -9,10 +13,14 @@ internal static class Program private static void Main(string[] args) { + var rootCommand = new RootCommand(); + ParseResult parseResult = rootCommand.Parse(args); + var parsedArgs = parseResult.Tokens.Select(token => token.Value).ToArray(); + var processHelper = new ProcessHelper(); var config = new Config(LocalStackHost); - var commandDispatcher = new CommandDispatcher(processHelper, config, args); + var commandDispatcher = new CommandDispatcher(processHelper, config, parsedArgs); commandDispatcher.Run(); } diff --git a/tests/LocalStack.AwsLocal.Tests/LocalStack.AwsLocal.Tests.csproj b/tests/LocalStack.AwsLocal.Tests/LocalStack.AwsLocal.Tests.csproj index c7c8397..2c5e14a 100644 --- a/tests/LocalStack.AwsLocal.Tests/LocalStack.AwsLocal.Tests.csproj +++ b/tests/LocalStack.AwsLocal.Tests/LocalStack.AwsLocal.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;netcoreapp2.1 true latest