{"id":13611620,"url":"https://github.com/unjs/citty","last_synced_at":"2025-06-10T22:42:18.188Z","repository":{"id":149529651,"uuid":"613874266","full_name":"unjs/citty","owner":"unjs","description":"🌆 Elegant CLI Builder","archived":false,"fork":false,"pushed_at":"2024-05-27T09:05:54.000Z","size":548,"stargazers_count":637,"open_issues_count":42,"forks_count":20,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-05-28T23:54:29.465Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-03-14T12:53:14.000Z","updated_at":"2024-05-30T14:11:17.306Z","dependencies_parsed_at":null,"dependency_job_id":"e9329c01-b8d7-4679-9bb6-5b5643aa3058","html_url":"https://github.com/unjs/citty","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fcitty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fcitty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fcitty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fcitty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unjs","download_url":"https://codeload.github.com/unjs/citty/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670513,"owners_count":21142896,"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":[],"created_at":"2024-08-01T19:01:59.068Z","updated_at":"2025-04-13T05:33:06.035Z","avatar_url":"https://github.com/unjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","others"],"sub_categories":[],"readme":"# 🌆 citty\n\n\u003c!-- automd:badges color=yellow bundlephobia --\u003e\n\n[![npm version](https://img.shields.io/npm/v/citty?color=yellow)](https://npmjs.com/package/citty)\n[![npm downloads](https://img.shields.io/npm/dm/citty?color=yellow)](https://npmjs.com/package/citty)\n[![bundle size](https://img.shields.io/bundlephobia/minzip/citty?color=yellow)](https://bundlephobia.com/package/citty)\n\n\u003c!-- /automd --\u003e\n\nElegant CLI Builder\n\n- Fast and lightweight argument parser based on [mri](https://github.com/lukeed/mri)\n- Smart value parsing with typecast, boolean shortcuts and unknown flag handling\n- Nested sub-commands\n- Lazy and Async commands\n- Pluggable and composable API\n- Auto generated usage and help\n\n🚧 This project is under heavy development. More features are coming soon!\n\n## Usage\n\nInstall package:\n\n```sh\n# npm\nnpm install citty\n\n# yarn\nyarn add citty\n\n# pnpm\npnpm install citty\n```\n\nImport:\n\n```js\n// ESM\nimport { defineCommand, runMain } from \"citty\";\n\n// CommonJS\nconst { defineCommand, runMain } = require(\"citty\");\n```\n\nDefine main command to run:\n\n```ts\nimport { defineCommand, runMain } from \"citty\";\n\nconst main = defineCommand({\n  meta: {\n    name: \"hello\",\n    version: \"1.0.0\",\n    description: \"My Awesome CLI App\",\n  },\n  args: {\n    name: {\n      type: \"positional\",\n      description: \"Your name\",\n      required: true,\n    },\n    friendly: {\n      type: \"boolean\",\n      description: \"Use friendly greeting\",\n    },\n  },\n  run({ args }) {\n    console.log(`${args.friendly ? \"Hi\" : \"Greetings\"} ${args.name}!`);\n  },\n});\n\nrunMain(main);\n```\n\n## Utils\n\n### `defineCommand`\n\n`defineCommand` is a type helper for defining commands.\n\n### `runMain`\n\nRuns a command with usage support and graceful error handling.\n\n### `createMain`\n\nCreate a wrapper around command that calls `runMain` when called.\n\n### `runCommand`\n\nParses input args and runs command and sub-commands (unsupervised). You can access `result` key from returnd/awaited value to access command's result.\n\n### `parseArgs`\n\nParses input arguments and applies defaults.\n\n### `renderUsage`\n\nRenders command usage to a string value.\n\n### `showUsage`\n\nRenders usage and prints to the console\n\n## Development\n\n- Clone this repository\n- Install latest LTS version of [Node.js](https://nodejs.org/en/)\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\nMade with 💛 Published under [MIT License](./LICENSE).\n\nArgument parser is based on [lukeed/mri](https://github.com/lukeed/mri) by Luke Edwards ([@lukeed](https://github.com/lukeed)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Fcitty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funjs%2Fcitty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Fcitty/lists"}