{"id":13903090,"url":"https://github.com/dword-design/make-cli","last_synced_at":"2025-10-30T12:31:19.158Z","repository":{"id":35475134,"uuid":"199673141","full_name":"dword-design/make-cli","owner":"dword-design","description":"Super easy declarative CLI framework with a single configuration object and a single function call.","archived":false,"fork":false,"pushed_at":"2024-05-01T15:20:37.000Z","size":2879,"stargazers_count":7,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T15:32:40.469Z","etag":null,"topics":["argument-parser","arguments","cli","command-line","command-line-interface","commander","commanderjs","declarative","declarative-programming","fp","functional","interface","node","nodejs","npm","npm-package","option","options"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/dword-design.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"custom":["buymeacoffee.com/dword","paypal.me/SebastianLandwehr"],"github":"dword-design","patreon":"dworddesign"}},"created_at":"2019-07-30T14:55:45.000Z","updated_at":"2024-05-02T17:44:48.773Z","dependencies_parsed_at":"2024-02-12T06:25:22.745Z","dependency_job_id":"e8daaf79-ea9a-4f77-92c4-ff7199e4cb58","html_url":"https://github.com/dword-design/make-cli","commit_stats":{"total_commits":216,"total_committers":12,"mean_commits":18.0,"dds":0.6666666666666667,"last_synced_commit":"24416bd3a11e5fc9a05741982966bf9640c5e6d6"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fmake-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fmake-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fmake-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fmake-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dword-design","download_url":"https://codeload.github.com/dword-design/make-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238968283,"owners_count":19560585,"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":["argument-parser","arguments","cli","command-line","command-line-interface","commander","commanderjs","declarative","declarative-programming","fp","functional","interface","node","nodejs","npm","npm-package","option","options"],"created_at":"2024-08-06T22:01:36.826Z","updated_at":"2025-10-30T12:31:19.151Z","avatar_url":"https://github.com/dword-design.png","language":"JavaScript","readme":"\u003c!-- TITLE/ --\u003e\n# make-cli\n\u003c!-- /TITLE --\u003e\n\n\u003c!-- BADGES/ --\u003e\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.org/package/make-cli\"\u003e\n    \u003cimg\n      src=\"https://img.shields.io/npm/v/make-cli.svg\"\n      alt=\"npm version\"\n    \u003e\n  \u003c/a\u003e\u003cimg src=\"https://img.shields.io/badge/os-linux%20%7C%C2%A0macos%20%7C%C2%A0windows-blue\" alt=\"Linux macOS Windows compatible\"\u003e\u003ca href=\"https://github.com/dword-design/make-cli/actions\"\u003e\n    \u003cimg\n      src=\"https://github.com/dword-design/make-cli/workflows/build/badge.svg\"\n      alt=\"Build status\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://codecov.io/gh/dword-design/make-cli\"\u003e\n    \u003cimg\n      src=\"https://codecov.io/gh/dword-design/make-cli/branch/master/graph/badge.svg\"\n      alt=\"Coverage status\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://david-dm.org/dword-design/make-cli\"\u003e\n    \u003cimg src=\"https://img.shields.io/david/dword-design/make-cli\" alt=\"Dependency status\"\u003e\n  \u003c/a\u003e\u003cimg src=\"https://img.shields.io/badge/renovate-enabled-brightgreen\" alt=\"Renovate enabled\"\u003e\u003cbr/\u003e\u003ca href=\"https://gitpod.io/#https://github.com/dword-design/make-cli\"\u003e\n    \u003cimg\n      src=\"https://gitpod.io/button/open-in-gitpod.svg\"\n      alt=\"Open in Gitpod\"\n      width=\"114\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://www.buymeacoffee.com/dword\"\u003e\n    \u003cimg\n      src=\"https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg\"\n      alt=\"Buy Me a Coffee\"\n      width=\"114\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://paypal.me/SebastianLandwehr\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/paypal.svg\"\n      alt=\"PayPal\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://www.patreon.com/dworddesign\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/patreon.svg\"\n      alt=\"Patreon\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!-- /BADGES --\u003e\n\n\u003c!-- DESCRIPTION/ --\u003e\nSuper easy declarative CLI framework with a single configuration object and a single function call.\n\u003c!-- /DESCRIPTION --\u003e\n\nThere are so many command line interface libraries around that it's hard to find the right one for your needs. But there aren't many that expose a single function with a single config object like most other Node.js packages do. That's why there is `make-cli`! Call a single function, pass a single config object and you're good to go.\n\nBased on [Commander.js](https://github.com/tj/commander.js) and supports most of its features. In case you're missing something, feel free to open up an [issue](https://github.com/dword-design/make-cli/issues).\n\n\u003c!-- INSTALL/ --\u003e\n## Install\n\n```bash\n# npm\n$ npm install make-cli\n\n# Yarn\n$ yarn add make-cli\n```\n\u003c!-- /INSTALL --\u003e\n\n## Usage\n\nCreate a `.js` file with Shebang and import `make-cli`. Then configure your command line tool like so:\n\n```js\n// cli.js\n\n#!/usr/bin/env node\n\nimport makeCli from 'make-cli'\n\nmakeCli({\n  version: '0.1.0',\n  name: 'my-cli',\n  usage: 'Usage description here',\n  arguments: '\u003cremote\u003e [extra]',\n  options: [\n    {\n      name: '-y, --yes',\n      description: 'Skip questions',\n    },\n    {\n      name: '--value \u003cvalue\u003e',\n      description: 'Specifies the value',\n      defaultValue: 'foo',\n      choices: ['foo', 'bar'],\n    },\n  ],\n  action: (remote, extra, options) =\u003e {\n    // options.value and options.yes\n    // contain the options.\n  },\n})\n```\n\nGive it execution rights via `chmod +x cli.js`.\n\nThen you can call it via the shell of your choice:\n\n```bash\n$ ./cli.js --yes\n$ ./cli.js foo\n$ ./cli.js --help\n$ ./cli.js --version\n```\n\nWhen publishing your command line tool via NPM, you'll probably want to add the file to the [bin](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#bin) property, so it's installed to `node_modules/.bin`.\n\n```json\n{\n  \"name\": \"my-cli\",\n  \"bin\": \"./cli.js\"\n}\n```\n\n### Subcommands\n\nIt is possible to define subcommands like so:\n\n```js\nmakeCli({\n  commands: [\n    {\n      name: 'push',\n      description: 'Pushes to the repo',\n      arguments: '\u003cremote\u003e',\n      options: [\n        {\n          name: '-y, --yes',\n        },\n      ],\n      handler: (remote, options) =\u003e { /* push the stuff */ },\n    },\n    {\n      name: 'pull',\n      // ...\n    },\n  ],\n})\n```\n\nThen you can call it:\n\n```bash\n$ ./cli.js push origin\n```\n\n### Declaring options and commands as objects\n\nInstead of an array you can declare options and commands as objects, which is sometimes more convenient:\n\n```js\nmakeCli({\n  options: [\n    '-y, --yes': { description: 'Skip questions' },\n    '--value \u003cvalue\u003e': {\n      description: 'Specifies the value',\n      defaultValue: 'foo',\n      choices: ['foo', 'bar'],\n    },\n  ],\n  commands: {\n    push: {\n      description: 'Pushes to the repo',\n      arguments: '\u003cremote\u003e',\n      options: [\n        {\n          name: '-y, --yes',\n        },\n      ],\n      handler: (remote, options) =\u003e { /* ... */ },\n    },\n    pull: () =\u003e { /* ... */ },\n  }\n})\n```\n\n### Unknown options\n\nYou can also allow to pass unknown options, which are then available in the action like so:\n\n```js\n#!/usr/bin/env node\n\nimport makeCli from 'make-cli'\n\nmakeCli({\n  // ...\n  allowUnknownOption: true,\n  options: [\n    {\n      name: '-y, --yes',\n      description: 'Skip questions',\n    },\n  ],\n  action: (options, command) =\u003e {\n    // options.yes = true\n    // command.args = ['--foo']\n  },\n})\n```\n\nIf you now run `$ ./cli.js --yes --foo`, `command.args` will contain `['--foo']`.\n\n\u003c!-- LICENSE/ --\u003e\n## Contribute\n\nAre you missing something or want to contribute? Feel free to file an [issue](https://github.com/dword-design/make-cli/issues) or a [pull request](https://github.com/dword-design/make-cli/pulls)! ⚙️\n\n## Support\n\nHey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:\n\n\u003cp\u003e\n  \u003ca href=\"https://www.buymeacoffee.com/dword\"\u003e\n    \u003cimg\n      src=\"https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg\"\n      alt=\"Buy Me a Coffee\"\n      width=\"114\"\n    \u003e\n  \u003c/a\u003e\u0026nbsp;If you want to send me a one time donation. The coffee is pretty good 😊.\u003cbr/\u003e\n  \u003ca href=\"https://paypal.me/SebastianLandwehr\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/paypal.svg\"\n      alt=\"PayPal\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\u0026nbsp;Also for one time donations if you like PayPal.\u003cbr/\u003e\n  \u003ca href=\"https://www.patreon.com/dworddesign\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/patreon.svg\"\n      alt=\"Patreon\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\u0026nbsp;Here you can support me regularly, which is great so I can steadily work on projects.\n\u003c/p\u003e\n\nThanks a lot for your support! ❤️\n\n## License\n\n[MIT License](https://opensource.org/license/mit/) © [Sebastian Landwehr](https://sebastianlandwehr.com)\n\u003c!-- /LICENSE --\u003e\n","funding_links":["buymeacoffee.com/dword","paypal.me/SebastianLandwehr","https://github.com/sponsors/dword-design","https://patreon.com/dworddesign","https://www.buymeacoffee.com/dword","https://paypal.me/SebastianLandwehr","https://www.patreon.com/dworddesign"],"categories":["cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdword-design%2Fmake-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdword-design%2Fmake-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdword-design%2Fmake-cli/lists"}