{"id":18573915,"url":"https://github.com/basedwon/cli","last_synced_at":"2025-04-10T07:32:40.685Z","repository":{"id":210812249,"uuid":"727493143","full_name":"basedwon/cli","owner":"basedwon","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-17T21:56:16.000Z","size":10,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-09T20:31:53.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/basedwon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-12-05T01:11:54.000Z","updated_at":"2024-02-17T20:38:02.000Z","dependencies_parsed_at":"2023-12-05T03:35:29.568Z","dependency_job_id":null,"html_url":"https://github.com/basedwon/cli","commit_stats":null,"previous_names":["basedwon/cli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basedwon","download_url":"https://codeload.github.com/basedwon/cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223430221,"owners_count":17143625,"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-11-06T23:13:22.885Z","updated_at":"2024-11-06T23:13:23.531Z","avatar_url":"https://github.com/basedwon.png","language":"JavaScript","readme":"# @basd/cli\n\n\u003e take command\n\n[![npm](https://img.shields.io/npm/v/@basd/cli?style=flat\u0026logo=npm)](https://www.npmjs.com/package/@basd/cli)\n[![pipeline](https://gitlab.com/frenware/utils/cli/badges/master/pipeline.svg)](https://gitlab.com/frenware/utils/cli/-/pipelines)\n[![license](https://img.shields.io/npm/l/@basd/cli)](https://gitlab.com/frenware/utils/cli/-/blob/master/LICENSE)\n[![downloads](https://img.shields.io/npm/dw/@basd/cli)](https://www.npmjs.com/package/@basd/cli) \n\n[![Gitlab](https://img.shields.io/badge/Gitlab%20-%20?logo=gitlab\u0026color=%23383a40)](https://gitlab.com/frenware/utils/cli)\n[![Github](https://img.shields.io/badge/Github%20-%20?logo=github\u0026color=%23383a40)](https://github.com/basedwon/cli)\n[![Twitter](https://img.shields.io/badge/@basdwon%20-%20?logo=twitter\u0026color=%23383a40)](https://twitter.com/basdwon)\n[![Discord](https://img.shields.io/badge/Basedwon%20-%20?logo=discord\u0026color=%23383a40)](https://discordapp.com/users/basedwon)\n\nA comprehensive Node.js module providing a set of tools for creating elegant command line interfaces by wrapping several popular CLI tools into one cohesive package. This project simplifies CLI development by combining functionality from various libraries, including command parsing, user interaction, and system command execution.\n\n## Features\n\n- **Commander Integration**: Leverages `commander` for powerful command-line interfaces.\n- **Progress and Spinner**: Includes `@basd/spinner`, a mix of `cli-spinner` and `cli-progress` for interactive CLI feedback.\n- **CLI Utilities**: Offers utilities from `basd` (a lodash wrapper), `shelljs` for shell commands, `prompts` for interactive user inputs, and `cli-color` for colorful CLI output.\n\n## Installation\n\nInstall `@basd/cli` using npm:\n\n```bash\nnpm install @basd/cli\n```\n\n## Usage\n\nThe `@basd/cli` module is designed to be intuitive for developers familiar with Node.js CLI development. Here's some examples to get you started:\n\n### Commander\n\nThe `commander` module in `@basd/cli` is used for building command-line interfaces with support for commands, options, and sub-commands.\n\n```js\nconst { program } = require('@basd/cli')\n\n// Define a new command with options\nprogram\n  .command('serve [port]')\n  .description('Start the server')\n  .option('-d, --debug', 'output extra debugging')\n  .action((port, options) =\u003e {\n    const portNumber = port || 3000\n    console.log(`Server running on port ${portNumber}`)\n    if (options.debug) console.log('Debugging mode is on')\n  })\n\n// Parse command-line arguments\nprogram.parse(process.argv)\n```\n\n### ShellJS\n\n`ShellJS` is integrated for executing shell commands in a Unix shell-style, but within your Node.js scripts.\n\n```js\nconst { shell } = require('@basd/cli')\n\n// Execute a simple UNIX command\nshell.exec('echo hello world')\n\n// Use it in a more complex scenario\nif (shell.exec('git status').code !== 0) {\n  shell.exit(1)\n}\n```\n\n### Prompts\n\nThe `prompts` module is excellent for creating interactive command-line prompts.\n\n```js\nconst cli = require('@basd/cli')\n\nasync function askName() {\n  const response = await cli.prompts({\n    type: 'text',\n    name: 'name',\n    message: 'What is your name?'\n  })\n\n  console.log(`Hello, ${response.name}!`)\n}\n\naskName()\n```\n\n### Progress and Spinner\n\n`Progress` and `Spinner` from `@basd/spinner` provide visual feedback for CLI applications.\n\n### Spinners\n\n```js\nconst { Spinner } = require('@basd/spinner')\n\nconst spinner = new Spinner({\n  id: 'unique-spinner-id', // optional\n  color: 'green', // optional\n  spinner: 'dots' // optional, spinner style\n})\n\nspinner.start('Loading...')\n// Update the spinner\nspinner.update('Still loading...')\n// Complete the spinner\nspinner.succeed('Completed!')\n```\n\n### Progress Bars\n\n```js\nconst { Progress } = require('@basd/spinner')\n\nconst progressBar = new Progress({\n  total: 100, // total value of the progress bar\n  preset: 'shades_classic' // optional, style of the progress bar\n})\n\nprogressBar.start(0)\n// Increment the progress\nprogressBar.increment(10)\n// Update the progress bar to a specific value\nprogressBar.update(50)\n// Complete the progress\nprogressBar.stop()\n```\n\n### Colors\n\n```js\nconst { colors } = require('@basd/cli')\n\nconsole.log(colors.red('This is a red text'))\n```\n\n## Documentation\n\n- [API Reference](/docs/api.md): Based on jsdoc comments.\n- [**commander**](https://npmjs.com/package/commander): Interface for defining commands and options.\n- [**Progress \u0026 Spinner**](https://npmjs.com/package/@basd/spinner): Utilities for displaying progress bars and spinners.\n- [**prompts**](https://npmjs.com/package/prompts): For creating interactive command-line prompts.\n- [**colors**](https://npmjs.com/package/cli-color): Enhance your CLI output with colored text.\n- [**shell**](https://npmjs.com/package/shelljs): Execute shell commands within your Node.js application.\n\n## Tests\n\nIn order to run the test suite, simply clone the repository and install its dependencies:\n\n```sh\ngit clone https://github.com/basedwon/cli.git\ncd cli\nnpm install\n```\n\nTo run the tests:\n\n```sh\nnpm test\n```\n\n## Contributing\n\nThank you! Please see our [contributing guidelines](/docs/contributing.md) for details.\n\n## Donations\n\nIf you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!\n\n**Bitcoin (BTC):**\n```\n1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF\n```\n\n**Monero (XMR):**\n```\n46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ\n```\n\n## License\n\n@basd/cli is [MIT licensed](https://gitlab.com/frenware/utils/cli/-/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasedwon%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Fcli/lists"}