{"id":20595284,"url":"https://github.com/myty/nu-plugin-lib","last_synced_at":"2025-11-17T15:07:23.052Z","repository":{"id":80523077,"uuid":"242050583","full_name":"myty/nu-plugin-lib","owner":"myty","description":"A .Net Standard class library for the sole purpose of building plugins for Nu Shell, https://github.com/nushell/nushell","archived":false,"fork":false,"pushed_at":"2024-07-09T21:18:32.000Z","size":107,"stargazers_count":16,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-26T11:02:38.546Z","etag":null,"topics":["csharp","nushell"],"latest_commit_sha":null,"homepage":"","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/myty.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-21T04:03:12.000Z","updated_at":"2025-04-09T10:15:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2c73ff5-59d5-4777-bcdf-8e4cee425ebb","html_url":"https://github.com/myty/nu-plugin-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/myty/nu-plugin-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fnu-plugin-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fnu-plugin-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fnu-plugin-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fnu-plugin-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myty","download_url":"https://codeload.github.com/myty/nu-plugin-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fnu-plugin-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284902887,"owners_count":27081965,"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-11-17T02:00:06.431Z","response_time":55,"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":["csharp","nushell"],"created_at":"2024-11-16T08:12:36.362Z","updated_at":"2025-11-17T15:07:23.041Z","avatar_url":"https://github.com/myty.png","language":"C#","readme":"# Nu.Plugin (.Net Standard 2.0)\n\nA .Net Standard class library for the sole purpose of building plugins for Nu Shell, https://github.com/nushell/nushell\n\nA Nu Shell plugin is any executable that macthes the pattern of `nu_plugin_*` so in essence, a .Net plugin for Nu Shell is a console application. At it's simplest form, a nu plugin is an application that reads the standard input stream and writes to the standard output stream. The communication protocol is done via [JSON-RPC](https://www.jsonrpc.org/). For more information: [Nu Plugins - Discovery](https://github.com/nushell/contributor-book/blob/master/en/plugins.md#discovery)\n\n## Motivations\n\nTo see how feasible it would be to create a plugin for Nu Shell in a language I am familiar with as well enjoy working in, C#. The biggest hurdle was figuring out how to communicate with the correct Json structure protocol. I personally like the vision for Nu Shell and am looking for ways to explore various avenues of getting others involved in the ecosystem.\n\nI used the [sample Python plugin](https://github.com/nushell/contributor-book/blob/master/en/plugins.md#creating-a-plugin-in-python) as the starting point and went from there.\n\nEventually I abstracted the plugin bits into their own class library, which should make it much easier for others to consume and begin making .Net Core Nu Shell plugins.\n\n## A Walk Through Creating Your First Plugin\n\nThis will go through the steps that would have gone into creating this \"len\" plugin\n\nFrom the command line:\n\n```cmd\ndotnet new console -o Nu.Plugin.Len\ncd Nu.Plugin.Len\ndotnet add package Nu.Plugin\n```\n\nOpen `Program.cs` and update to the following:\n\n```csharp\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Nu.Plugin.Interfaces;\n\nnamespace Nu.Plugin.Len\n{\n    class Program : INuPluginFilter\n    {\n        static async Task Main(string[] args) =\u003e await NuPlugin.Create()\n            .Name(\"len\")\n            .Usage(\"Return the length of a string\")\n            .IsFilter\u003cProgram\u003e()\n            .RunAsync();\n\n        public object BeginFilter() =\u003e Array.Empty\u003cstring\u003e();\n\n        public JsonRpcParams Filter(JsonRpcParams requestParams)\n        {\n            var stringLength = requestParams.Value.Primitive[\"String\"].ToString().Length;\n\n            requestParams.Value.Primitive = new Dictionary\u003cstring, object\u003e{\n                {\"Int\", stringLength}\n            };\n\n            return requestParams;\n        }\n\n        public object EndFilter() =\u003e Array.Empty\u003cstring\u003e();\n    }\n}\n```\n\nOpen `Nu.Plugin.Len.csproj` and add the `AssemblyName` element to the `PropertyGroup` like so:\n\n```xml\n\u003cPropertyGroup\u003e\n    \u003cAssemblyName\u003enu_plugin_len\u003c/AssemblyName\u003e\n    \u003cOutputType\u003eExe\u003c/OutputType\u003e\n    \u003cTargetFramework\u003e...\u003c/TargetFramework\u003e\n\u003c/PropertyGroup\u003e\n```\n\nThe key takeaway is that Nu searches for any executable file within the path named `nu_plugin_*` to be included as plugins. By updating the assembly name to this pattern, it will create an executable with the name, `nu_plugin_len`, For more information: [Nu Plugins - Discovery](https://github.com/nushell/contributor-book/blob/master/en/plugins.md#discovery)\n\nBuild the project:\n```cmd\ndotnet build\n```\n\n** Note: Update your OS settings to include the PATH to the debug directory where the `nu_plugin_len` executable was created.  Next time you start Nu Shell, it will now discover your newly created .Net Core executable as Nu plugin.\n\nRun from within Nu shell:\n\n```shell\necho \"Hello, world\" | len\n```\n\n![Nu Shell Len Plugin](/assets/img/dotnet-nu-plugin-len.gif)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyty%2Fnu-plugin-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyty%2Fnu-plugin-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyty%2Fnu-plugin-lib/lists"}