{"id":13495133,"url":"https://github.com/arcanis/clipanion","last_synced_at":"2025-05-14T03:06:36.769Z","repository":{"id":40589396,"uuid":"87702856","full_name":"arcanis/clipanion","owner":"arcanis","description":"Type-safe CLI library / framework with no runtime dependencies","archived":false,"fork":false,"pushed_at":"2024-09-06T09:16:49.000Z","size":12089,"stargazers_count":1159,"open_issues_count":37,"forks_count":67,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-10T17:05:13.341Z","etag":null,"topics":["cli","typescript"],"latest_commit_sha":null,"homepage":"https://mael.dev/clipanion/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arcanis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2017-04-09T11:13:57.000Z","updated_at":"2025-05-02T02:50:24.000Z","dependencies_parsed_at":"2024-05-29T09:54:09.204Z","dependency_job_id":null,"html_url":"https://github.com/arcanis/clipanion","commit_stats":{"total_commits":274,"total_committers":24,"mean_commits":"11.416666666666666","dds":"0.44160583941605835","last_synced_commit":"f52f6ae39308ebdf3d1d7e0b8536faa97d836ea1"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fclipanion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fclipanion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fclipanion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arcanis%2Fclipanion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arcanis","download_url":"https://codeload.github.com/arcanis/clipanion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059500,"owners_count":22007768,"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","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":["cli","typescript"],"created_at":"2024-07-31T19:01:31.431Z","updated_at":"2025-05-14T03:06:36.722Z","avatar_url":"https://github.com/arcanis.png","language":"TypeScript","funding_links":[],"categories":["Repository","TypeScript","cli","Packages","**1. Libraries**","[JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)","Node.js / JavaScript 🟨"],"sub_categories":["Command-line Utilities","Others","Useful awesome list for Go cli"],"readme":"# \u003cimg src=\"./logo.svg\" height=\"25\" /\u003e Clipanion\n\n\u003e Type-safe CLI library with no runtime dependencies\n\n[![npm version](https://img.shields.io/npm/v/clipanion.svg)](https://yarnpkg.com/package/clipanion) [![Licence](https://img.shields.io/npm/l/clipanion.svg)](https://github.com/arcanis/clipanion#license-mit) [![Yarn](https://img.shields.io/github/package-json/packageManager/arcanis/clipanion)](https://github.com/yarnpkg/berry)\n\n## Installation\n\n```sh\nyarn add clipanion\n```\n\n## Why\n\n- Clipanion supports advanced typing mechanisms\n- Clipanion supports nested commands (`yarn workspaces list`)\n- Clipanion supports transparent option proxying without `--` (for example `yarn dlx eslint --fix`)\n- Clipanion supports all option types you could think of (including negations, batches, ...)\n- Clipanion offers a [Typanion](https://github.com/arcanis/typanion) integration for increased validation capabilities\n- Clipanion generates an optimized state machine out of your commands\n- Clipanion generates good-looking help pages out of the box\n- Clipanion offers common optional command entries out-of-the-box (e.g. version command, help command)\n\nClipanion is used in [Yarn](https://github.com/yarnpkg/berry) with great success.\n\n## Documentation\n\nCheck the website for our documentation: [mael.dev/clipanion](https://mael.dev/clipanion/).\n\n## Migration\n\nYou can use [`clipanion-v3-codemod`](https://github.com/paul-soporan/clipanion-v3-codemod) to migrate a Clipanion v2 codebase to v3.\n\n## Overview\n\nCommands are declared by extending from the `Command` abstract base class, and more specifically by implementing its `execute` method which will then be called by Clipanion. Whatever exit code it returns will then be set as the exit code for the process:\n\n```ts\nclass SuccessCommand extends Command {\n    async execute() {\n        return 0;\n    }\n}\n```\n\nCommands can also be exposed via one or many arbitrary paths using the `paths` static property:\n\n```ts\nclass FooCommand extends Command {\n    static paths = [[`foo`]];\n    async execute() {\n        this.context.stdout.write(`Foo\\n`);\n    }\n}\n\nclass BarCommand extends Command {\n    static paths = [[`bar`]];\n    async execute() {\n        this.context.stdout.write(`Bar\\n`);\n    }\n}\n```\n\nOptions are defined as regular class properties, annotated by the helpers provided in the `Option` namespace. If you use TypeScript, all property types will then be properly inferred with no extra work required:\n\n```ts\nclass HelloCommand extends Command {\n    // Positional option\n    name = Option.String();\n\n    async execute() {\n        this.context.stdout.write(`Hello ${this.name}!\\n`);\n    }\n}\n```\n\nOption arguments can be validated and coerced using the [Typanion](https://mael.dev/typanion/) library:\n\n```ts\nclass AddCommand extends Command {\n    a = Option.String({required: true, validator: t.isNumber()});\n    b = Option.String({required: true, validator: t.isNumber()});\n\n    async execute() {\n        this.context.stdout.write(`${this.a + this.b}\\n`);\n    }\n}\n```\n\n## License (MIT)\n\n\u003e **Copyright © 2019 Mael Nison**\n\u003e\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\u003e\n\u003e The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\u003e\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcanis%2Fclipanion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farcanis%2Fclipanion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcanis%2Fclipanion/lists"}