{"id":13902890,"url":"https://github.com/yjl9903/Breadc","last_synced_at":"2025-07-18T00:32:30.480Z","repository":{"id":37365827,"uuid":"505298867","full_name":"yjl9903/Breadc","owner":"yjl9903","description":"🥪 Yet another Command Line Application Framework with fully TypeScript support","archived":false,"fork":false,"pushed_at":"2024-04-13T22:11:30.000Z","size":2347,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T12:14:10.162Z","etag":null,"topics":["cli","command-line","framework","typescript","vscode"],"latest_commit_sha":null,"homepage":"https://breadc.onekuma.cn/","language":"TypeScript","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/yjl9903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-20T04:55:38.000Z","updated_at":"2024-04-16T11:45:01.842Z","dependencies_parsed_at":"2023-09-24T05:00:38.913Z","dependency_job_id":"63b90324-2173-4a01-a10d-5430b307d740","html_url":"https://github.com/yjl9903/Breadc","commit_stats":{"total_commits":399,"total_committers":2,"mean_commits":199.5,"dds":"0.44611528822055135","last_synced_commit":"ece59d6e98d306ca7e699ee0771bbfeb94555b79"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2FBreadc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2FBreadc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2FBreadc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2FBreadc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjl9903","download_url":"https://codeload.github.com/yjl9903/Breadc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":214260313,"owners_count":15707076,"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","command-line","framework","typescript","vscode"],"created_at":"2024-08-06T22:01:29.014Z","updated_at":"2025-07-18T00:32:30.453Z","avatar_url":"https://github.com/yjl9903.png","language":"TypeScript","readme":"# 🥪 Breadc\n\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/yjl9903/Breadc)\n[![version](https://img.shields.io/npm/v/breadc?label=Breadc)](https://www.npmjs.com/package/breadc)\n[![CI](https://github.com/yjl9903/Breadc/actions/workflows/ci.yml/badge.svg)](https://github.com/yjl9903/Breadc/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/yjl9903/Breadc/branch/main/graph/badge.svg?token=F7PGOG62EF)](https://codecov.io/gh/yjl9903/Breadc)\n\nYet another Command Line Application Framework with fully strong **[TypeScript](https://www.typescriptlang.org/) support**.\n\n![vscode](https://cdn.jsdelivr.net/gh/yjl9903/Breadc/images/vscode.png)\n\n## Features\n\n+ 🔍 **TypeScript Infer**: IDE will automatically infer the type of your command action function;\n+ 💻 **Commands**: support default command, command alias and sub-commands like `git remote add \u003cname\u003e \u003curl\u003e`;\n+ 📖 **East to Learn**: very similar with [commander.js](https://github.com/tj/commander.js/), [cac](https://github.com/cacjs/cac) and there are only 5 APIs for building a CLI application: `breadc`, `command`, `option`, `action`, `run`.\n+ 🧰 **Toolkits**: contains many useful tools to build your next CLI application, such as [ansi color](https://github.com/yjl9903/Breadc/tree/main/packages/color), [process death handler](https://github.com/yjl9903/Breadc/tree/main/packages/death), [shell compelete script generation](https://github.com/yjl9903/Breadc/tree/main/packages/complete) and so on.\n\n## Installation\n\n```bash\nnpm i breadc\n```\n\n## Usage\n\nTry [./examples/echo.ts](./examples/echo.ts).\n\n```ts\nimport { breadc } from 'breadc'\n\nconst cli = breadc('echo', { version: '1.0.0' })\n  .option('--host \u003chost\u003e', { default: 'localhost' })\n  .option('--port \u003cport\u003e', { default: '3000', cast: p =\u003e +p })\n\ncli\n  .command('[message]', 'Say something!')\n  .action((message, option) =\u003e {\n    const host = option.host\n    const port = option.port\n    console.log(`Host: ${host}`)\n    console.log(`Port: ${port}`)\n  })\n\ncli.run(process.argv.slice(2)).catch(err =\u003e console.error(err))\n```\n\nIf you are using IDEs that support TypeScript (like [Visual Studio Code](https://code.visualstudio.com/)), input something using `option`, and then you will find the `option` is automatically typed with `{ host: string, port: number }`. In the figure below, [Visual Studio Code](https://code.visualstudio.com/) will automatically infer that the type of `option.host` is `string` and the type of `option.port` is `number`.\n\n![vscode](https://cdn.jsdelivr.net/gh/yjl9903/Breadc/images/vscode.png)\n\n### Limitation\n\nFor the limitation of TypeScript, in the command format string, you can only write up to **5** pieces. That is to say, you can only write format string like `\u003cp1\u003e \u003cp2\u003e \u003cp3\u003e \u003cp4\u003e [p5]`, but `\u003cp1\u003e \u003cp2\u003e \u003cp3\u003e \u003cp4\u003e \u003cp5\u003e [p6]` does not work.\n\nYou should always use method chaining when registering options and commands. The example below will fail to infer the option `--host`.\n\n```ts\nimport { breadc } from 'breadc'\n\nconst cli = breadc('cli')\n\ncli\n  .option('--host')\n\ncli\n  .option('--port')\n  .command('')\n  .action((option) =\u003e {\n    // The type of option is only { port: boolean }\n  })\n```\n\n## Inspiration\n\n+ [cac](https://github.com/cacjs/cac): Simple yet powerful framework for building command-line apps.\n+ [TypeScript: Documentation - Template Literal Types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html)\n\n## License\n\nMIT License © 2023 [XLor](https://github.com/yjl9903)\n","funding_links":[],"categories":["cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjl9903%2FBreadc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjl9903%2FBreadc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjl9903%2FBreadc/lists"}