{"id":23171038,"url":"https://github.com/ignatandrei/webapi2cli","last_synced_at":"2025-08-18T07:32:03.739Z","repository":{"id":52834451,"uuid":"245025238","full_name":"ignatandrei/WebAPI2CLI","owner":"ignatandrei","description":"Execute ASP.NET Core WebAPI from Command Line","archived":false,"fork":false,"pushed_at":"2024-07-09T21:19:18.000Z","size":42040,"stargazers_count":29,"open_issues_count":15,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T05:49:34.474Z","etag":null,"topics":["asp-net-core","cli","csharp","visual-studio","webapi"],"latest_commit_sha":null,"homepage":"https://ignatandrei.github.io/WebAPI2CLI/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ignatandrei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-04T23:26:09.000Z","updated_at":"2023-01-12T04:37:49.000Z","dependencies_parsed_at":"2022-08-22T13:51:29.598Z","dependency_job_id":null,"html_url":"https://github.com/ignatandrei/WebAPI2CLI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ignatandrei/WebAPI2CLI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FWebAPI2CLI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FWebAPI2CLI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FWebAPI2CLI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FWebAPI2CLI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ignatandrei","download_url":"https://codeload.github.com/ignatandrei/WebAPI2CLI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FWebAPI2CLI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270961626,"owners_count":24675914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","cli","csharp","visual-studio","webapi"],"created_at":"2024-12-18T04:15:57.758Z","updated_at":"2025-08-18T07:31:58.725Z","avatar_url":"https://github.com/ignatandrei.png","language":"C#","readme":"# WebAPI2CLI\nExecute ASP.NET Core WebAPI from Command Line . Source at https://github.com/ignatandrei/WebAPI2CLI\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ignatandrei/WebAPI2CLI/blob/master/LICENSE)\n[![NuGet](https://img.shields.io/nuget/v/ExtensionNetCore3.svg)](https://www.nuget.org/packages/ExtensionNetCore3)\n![MyGet](https://img.shields.io/myget/ignatandrei/v/ExtensionNetCore3?label=CD2MyGet)\n[![Build Status](https://dev.azure.com/ignatandrei0674/WebAPI2CLI/_apis/build/status/ignatandrei.WebAPI2CLI?branchName=master)](https://dev.azure.com/ignatandrei0674/WebAPI2CLI/_build/latest?definitionId=7\u0026branchName=master)\n![Azure DevOps tests (branch)](https://img.shields.io/azure-devops/tests/ignatandrei0674/WebAPI2CLI/7/master)\n![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/ignatandrei0674/WebAPI2CLI/7/master)\n![generateDocs](https://github.com/ignatandrei/webAPI2CLI/workflows/generateDocs/badge.svg)\n\n# Why\n\nWhat if, instead of running the WebAPI ( or just the site ) and waiting for commands from the user, you want also to execute from the command line some controllers actions ?\n\nThis project let's you do that by enabling the command line with \n\n \u0026lt; myexe \u0026gt;.exe --CLI_ENABLED=1 --CLI_Commands=\" ... \" \n\nThe command names are in a *cli.txt* file that can be generated with\n\n \u0026lt; myexe \u0026gt;.exe --CLI_ENABLED=1 --CLI_HELP=1\n\n\n# How to use ( for .NET Core 3.1 )\n\n## Step 0 : install into your ASP.NET Core Web \n\nInstall the package https://www.nuget.org/packages/ExtensionNetCore3\n\nModify your ASP.NET Core as below:\n\n```csharp\npublic void ConfigureServices(IServiceCollection services)\n{\n    services.AddCLI();\n//your code omitted\n}    \npublic void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n{\n    app.UseCLI();\n//your code omitted\n}       \n```\nAnd that is all modifications that you need to do for the source code.\n\n## Step 1 - find and save the definition of the commands, i.e. WebAPI endpoints\n\nFirst, you must generate the definition of the commands. For this, we take the OPEN API (swagger ) approach.\n\nFor this, after you compile the project, you will run your .exe program with arguments:\n \n \u0026lt; myexe \u0026gt;.exe --CLI_ENABLED=1 --CLI_HELP=1\n\n( or make this from *Visual Studio, Project, Properties, Debug* )\n\nThis will generate a *cli.txt* file with all definitions of the WebAPI.\n( if your API does not appear, check if you have *ApiController* defined)\n\nOpen your *cli.txt*  file and modify the names of the commands as you wish (also , the arguments )\n\nCopy this *cli.txt* in your solution and be sure that is copied with the exe ( in Visual Studio right click the file, properties, Build Action = Content, CopyToOutputDirectory = Copy if newer)\n\n## Step 2 - run the commands\n\nEnsure that the file is near your exe WebAPI.\n\nRun the exe with the following:\n\n \u0026lt; myexe \u0026gt;.exe --CLI_ENABLED=1 --CLI_Commands=\"your first command,your second command, and enumerate all commands\"\n\nThe program will run the commands and output the result.\n\n## Optional Step 3 - letting others download the app to use as CLI\nModify the endpoints to add zip\n\n```csharp\n app.UseEndpoints(endpoints =\u003e\n            {\n                endpoints.MapControllers();\n\n                endpoints.MakeZip(app);\n            });\n```\nand browser to \u003croot of the site\u003e/zip  to download the whole application.\nMore details here( including a demo)\n\nhttps://ignatandrei.github.io/WebAPI2CLI/\n\n\nEnvironment Variables: see https://github.com/ignatandrei/Interpreter \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignatandrei%2Fwebapi2cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignatandrei%2Fwebapi2cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignatandrei%2Fwebapi2cli/lists"}