{"id":21391350,"url":"https://github.com/ottomatica/cli-template","last_synced_at":"2025-03-16T13:22:10.771Z","repository":{"id":38301762,"uuid":"272608958","full_name":"ottomatica/cli-template","owner":"ottomatica","description":"🥣 A minimalistic Node.js cli app biolerplate","archived":false,"fork":false,"pushed_at":"2023-01-24T16:01:06.000Z","size":169,"stargazers_count":1,"open_issues_count":12,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-23T01:11:21.348Z","etag":null,"topics":["biolerplate","cli-app","template"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ottomatica.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":"2020-06-16T04:25:27.000Z","updated_at":"2020-12-31T01:49:55.000Z","dependencies_parsed_at":"2023-02-13T23:16:12.441Z","dependency_job_id":null,"html_url":"https://github.com/ottomatica/cli-template","commit_stats":null,"previous_names":[],"tags_count":2,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fcli-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fcli-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fcli-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottomatica%2Fcli-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ottomatica","download_url":"https://codeload.github.com/ottomatica/cli-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243872640,"owners_count":20361523,"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":["biolerplate","cli-app","template"],"created_at":"2024-11-22T13:26:05.909Z","updated_at":"2025-03-16T13:22:10.741Z","avatar_url":"https://github.com/ottomatica.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cli-template 🥣 | ![CI](https://github.com/ottomatica/cli-template/workflows/CI/badge.svg)\n\nThis repo contains a minimalistic Node.js cli app biolerplate to quickly get started with creating your next cli app ✨\n\n## Get Started\n\n- Clone this repository:\n\n  ```bash\n  git clone https://github.com/ottomatica/cli-template.git\n  cd cli-template\n  npm link\n  ```\n\n- Try running a command:\n\n  ```bash\n  cli-template start a b --force\n  ```\n\n## Define Commands\n\nCommands are define in [`./lib/commands/*.js`](./lib/commands). This template includes a simple command called [start](./lib/commands/start.js) (the same command you tried above ☝️) which you can use as a template for your next commands. Simply make a copy of start.js file and update properties of the command:\n\n```js\nexports.command = 'start \u003cfoo\u003e [bar]';          // \u003c--- This is where you define the command name and args\n                                                //        \u003cfoo\u003e is a required, and [bar] is optional\n\nexports.desc = 'This is the start command';     // \u003c--- The command description shown when you run `--help`\n\nexports.builder = yargs =\u003e {\n    yargs.options({                             // \u003c--- Add as many options you need here\n        force: {\n            alias: ['f', 'ff'],\n            describe: 'Description for force options',\n            default: false,\n            type: 'boolean'\n        },\n    });\n                                                // \u003c--- optionally add an example to `--help` command\n    yargs.example(`$0 start foo`, `Example of how to use this command`);\n};\n\nexports.handler = async argv =\u003e {\n    const { foo, bar, force } = argv;           // \u003c--- In this command handler you can get the cli args and \n                                                //        use them to implement the command actions\n\n    console.log({foo, bar, force});\n};\n```\n\n\u003e _Note: the command name is what you specify in `exports.command` property of the file, not the name of the file you create._\n\nSince we are using [Yargs](https://www.npmjs.com/package/yargs) for creating these commands, by setting the properties mentioned above, we will also get a nice `--help` command automatically:\n\n```bash\n$ cli-template start --help\n\ncli-template start \u003cfoo\u003e [bar]\n\nThis is the start command\n\nOptions:\n  --version          Show version number                                           [boolean]\n  --help             Show help                                                     [boolean]\n  --force, -f, --ff  Description for force options                [boolean] [default: false]\n\nExamples:\n  cli-template start foo      Example of how to use this command\n```\n\n## Testing\n\nThis template also includes basic setup for your integration tests. You can find an example of running this `cli-template` app in [`./test/test.js`](./test/test.js).\n\n```bash\n$ npm test\n\nPASS  test/test.js\n  Run start command\n    ✓ Running `$ cli-template start a b --force` (80 ms)\n\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        0.948 s, estimated 1 s\nRan all test suites.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fottomatica%2Fcli-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fottomatica%2Fcli-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fottomatica%2Fcli-template/lists"}