{"id":28713199,"url":"https://github.com/andreaspitzer/yargsify","last_synced_at":"2025-06-26T16:33:15.983Z","repository":{"id":258340772,"uuid":"873687456","full_name":"andreaspitzer/yargsify","owner":"andreaspitzer","description":"Test and run yargs commands","archived":false,"fork":false,"pushed_at":"2024-10-16T14:57:22.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T13:11:46.342Z","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/andreaspitzer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T14:51:56.000Z","updated_at":"2024-10-16T14:57:27.000Z","dependencies_parsed_at":"2024-10-19T02:34:55.815Z","dependency_job_id":null,"html_url":"https://github.com/andreaspitzer/yargsify","commit_stats":null,"previous_names":["andreaspizsa/yargsify","andreaspitzer/yargsify"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andreaspitzer/yargsify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreaspitzer%2Fyargsify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreaspitzer%2Fyargsify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreaspitzer%2Fyargsify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreaspitzer%2Fyargsify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreaspitzer","download_url":"https://codeload.github.com/andreaspitzer/yargsify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreaspitzer%2Fyargsify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262102334,"owners_count":23259239,"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":"2025-06-15T00:08:25.059Z","updated_at":"2025-06-26T16:33:15.944Z","avatar_url":"https://github.com/andreaspitzer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yargsify\n\n\u003e Test and run [yargs](https://yargs.js.org/) commands.\n\n## Features\n`yargsify` lets you define yargs commands and run them as either standalone commands\nor as part of a larger cli program.\n\nWhen running as standalone app, it also adds several options that are common for\nmany CLI tools and helps manage command execution.\n\n- `--debug`: Enables debug mode. When disabled, `console.debug` will be\n  set to a no-op to prevent debug logs from appearing.\n- `--quiet` (`-q`): Suppresses non-critical output by setting\n  `console.log` to a no-op.\n- `--verbose` (`-v`): Enables verbose output. When disabled, `console.info`\n  is set to a no-op to suppress additional information.\n\nThe function uses `esMain` to ensure that the commands are executed only\nwhen the script is run directly, not when imported as a module.\n\n- **Standalone or Larger CLI Integration**: By using `esMain`, this function\n  allows commands to be executed either as standalone scripts or as part of\n  a larger CLI application. When used in isolation, the script can run\n  independently, but when imported into a larger CLI app, it can contribute\n  its functionality without immediate execution, enabling modular\n  development of CLI tools.\n- **Modularity**: By only executing the command logic when run directly, the\n  script can be imported into other projects or modules without triggering\n  its main functionality. This makes the code more reusable and easier to\n  integrate with other codebases.\n- **Testing and Reusability**: If the script is imported into a test\n  environment, the functionality does not automatically execute, which allows\n  easier unit testing. It also makes it easier to reuse the functions and\n  commands elsewhere without worrying about unintended side effects.\n- **Clear Separation**: It creates a clear separation between the module’s\n  executable logic and its reusable components. When imported, only the\n  functions and utilities are available, without executing the primary\n  script, promoting better coding practices and maintainability.\n\nIt processes command line arguments and sets up the given command along\nwith additional options using yargs.\n\n## Example usage\n```js\nimport yargsify from 'yargsify'\n\nconst yargsCommand = {\n  command: 'greet \u003cname\u003e',\n  describe: 'Greet a user by name',\n  builder: (yargs) =\u003e yargs.positional('name', {\n    type: 'string',\n    describe: 'The name of the user to greet'\n  }),\n  handler: (argv) =\u003e {\n    console.log(`Hello, ${argv.name}!`)\n  }\n}\n\nyargsify(yargsCommand, import.meta)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreaspitzer%2Fyargsify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreaspitzer%2Fyargsify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreaspitzer%2Fyargsify/lists"}