{"id":16278600,"url":"https://github.com/sigoden/clii","last_synced_at":"2026-03-05T12:32:34.547Z","repository":{"id":43684448,"uuid":"459128501","full_name":"sigoden/clii","owner":"sigoden","description":"Easily build a cli app.","archived":false,"fork":false,"pushed_at":"2022-02-24T00:56:51.000Z","size":640,"stargazers_count":42,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-02T07:37:38.217Z","etag":null,"topics":["command-line","command-runner","javascript","make"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigoden.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":"2022-02-14T11:08:55.000Z","updated_at":"2025-10-08T20:36:17.000Z","dependencies_parsed_at":"2022-08-31T03:41:00.600Z","dependency_job_id":null,"html_url":"https://github.com/sigoden/clii","commit_stats":null,"previous_names":["sigoden/cmru"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sigoden/clii","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fclii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fclii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fclii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fclii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigoden","download_url":"https://codeload.github.com/sigoden/clii/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigoden%2Fclii/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30124467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T11:11:57.947Z","status":"ssl_error","status_checked_at":"2026-03-05T11:11:29.001Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["command-line","command-runner","javascript","make"],"created_at":"2024-10-10T18:59:10.680Z","updated_at":"2026-03-05T12:32:34.506Z","avatar_url":"https://github.com/sigoden.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clii\n\nEasily build a cli app.\n\nWrite some functions, jsdoc it, clii automatically turns it into a cli.\n\n![examples/demo.mjs](https://user-images.githubusercontent.com/4012553/154807539-f8f554f5-82da-4d3b-8cc8-578cfc661535.png)\n\n- [Clii](#clii)\n  - [Quick Start](#quick-start)\n  - [Cli Tool](#cli-tool)\n  - [License](#license)\n\n## Quick Start\n\nInstall clii package.\n\n```\nnpm i clii\nyarn add clii\n```\n\n Write some js code\n\n```js\n/**\n * A simple task\n * @param {Object} options\n * @param {number} options.num - Num variable\n * @param {(\"prod\"|\"dev\"|\"stage\")} options.mode - Build mode\n */\nexport async function task(options) {\n  console.log(options);\n}\n```\n\nAdd follow content to your file.\n\n```js\nimport clii from \"clii\";\n\nclii(import.meta.url);\n```\n\nAll done.\n\nWhat an easy way to build the cli app.\n\nTry it in your terminal\n```\n$ node index.mjs task1 -h\nindex.mjs task1 [options]\n\nOptions:\n      --version  Show version number                                   [boolean]\n  -f, --file     Specific clii file                                     [string]\n  -w, --workdir  Specific working directory                             [string]\n      --num      Num variable                                           [number]\n      --mode     Build mode           [string] [choices: \"prod\", \"dev\", \"stage\"]\n  -h, --help     Show help                                             [boolean]\n\n$ node index.mjs task --num 3 --mode prod\n{ num: 3, mode: 'prod' }\n```\n\n`clii` parse your ast js module file, generate cli interface according comments and exports semantics.\n\nExport variable `settings` will be parsed as global options.\n```\nexport const settings = {\n  // Default port number\n  port: 3000,\n};\n```\n```\nOptions:\n      --port     Default port number                    [number] [default: 3000]\n```\n\nExport function `cmd2` will be parsed as subcommand. It's parameters will be parsed as subcommand's options.\n\n```\nCommands:\n  demo.mjs cmd2 \u003cmessage\u003e [options]  Another command\n```\n\nThe export default function will be th default command.\n\n## Cli Tool\n\nSince `clii` can run js functions directly from cli, it can be used as task runner / build tool.\n\nBy default, `clii` looks for file `cliifile.mjs` in the current directory and upwards, so you can invoke it from any subdirectory of your project. \n\nYou can organize your project scripts with `cliifile.mjs` to provide unified entrypoint and help information.\n\n```js\nexport function lint() {}\n/**\n * Build\n * @param {Object} options\n * @param {boolean} options.prod\n */\nexport function build(options) {\n  lint();\n}\n```\n\n```\n$ clii\nUsage: clii \u003ccmd\u003e [options]\n\nCommands:\n  clii lint\n  clii build [options]  Build\n\nOptions:\n      --version  Show version number                                   [boolean]\n  -f, --file     Specific clii file                                     [string]\n  -w, --workdir  Specific working directory                             [string]\n  -h, --help     Show help                                             [boolean]\n\n$ clii build\n$ clii lint\n```\n\n\n## License\n\n[Apache-2.0](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigoden%2Fclii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigoden%2Fclii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigoden%2Fclii/lists"}