{"id":22505195,"url":"https://github.com/azer/new-command","last_synced_at":"2025-10-28T20:52:06.229Z","repository":{"id":13876010,"uuid":"16574027","full_name":"azer/new-command","owner":"azer","description":"Simplifies creating CLI programs by combining minimist, show-help, show-version modules.","archived":false,"fork":false,"pushed_at":"2016-06-05T10:56:16.000Z","size":8,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-14T10:06:22.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-06T09:15:33.000Z","updated_at":"2021-12-16T14:13:33.000Z","dependencies_parsed_at":"2022-07-21T17:04:31.553Z","dependency_job_id":null,"html_url":"https://github.com/azer/new-command","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-command","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-command/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-command/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-command/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azer","download_url":"https://codeload.github.com/azer/new-command/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228540833,"owners_count":17934031,"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-12-07T00:15:53.019Z","updated_at":"2025-10-28T20:52:01.195Z","avatar_url":"https://github.com/azer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## new-command\n\nSimplifies creating command-line programs by combining [minimist](http://github.com/substack/minimist), [show-help](http://github.com/azer/show-help), [show-version](http://github.com/azer/show-version) modules.\n\nUsage Examples: [prova](https://github.com/azer/prova/blob/master/bin/prova#L3), [bud](https://github.com/azer/bud/blob/master/lib/cli.js#L9), [personal-api](https://github.com/azer/personal-api/blob/master/bin/personal-api.js#L3), [ourtunes](https://github.com/azer/ourtunes/blob/master/bin/ourtunes.js#L5)\n\n## Install\n\n```bash\n$ npm install new-command\n```\n\n## Usage\n\n### Defining Parameters\n\nDefine a command and options by calling new-command:\n\n```js\nvar command = require('new-command')({ 'p': 'port', 'n': 'hostname' })\n\ncommand.port\n// =\u003e 8080\n\ncommand.hostname\n// =\u003e foobar.com\n\ncommand._\n// =\u003e ['rest', 'of the', 'arguments']\n```\n\n## Subcommands\n\nTo define subcommands like `git push` `npm publish` etc, just pass subcommand names before options:\n\n```js\ncommand = require('new-command')('install', 'publish', 'unpublish', { r: 'registry', s: 'save' })\n\n\n\ncommand.install\n// =\u003e undefined\n\ncommand.publish\n// =\u003e true\n\ncommand._subcommand\n// =\u003e 'publish'\n```\n\n### --version and --help\n\n`new-command` will take care of `--version` (-v) and `--help` (-h) options\nfor you, by calling [show-version](http://github.com/azer/show-version) and [show-help](http://github.com/azer/show-help). So, if you call this command with -v parameter:\n\n```bash\n$ start-server --version\n\nstart-server v0.0.0\n```\n\nIt reads your package name and version and outputs automatically. When user calls -h parameter:\n\n```bash\n$ start-server --help\n```\n\nIt'll look for following paths in the project directory and will output the one it finds first:\n\n* docs/man\n* bin/help.txt\n* bin/usage.txt\n* help.txt\n* usage.txt\n* README\n* README.md\n* README.markdown\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fnew-command","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazer%2Fnew-command","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fnew-command/lists"}