{"id":19262742,"url":"https://github.com/documentationjs/zeroarg","last_synced_at":"2025-04-21T18:31:13.422Z","repository":{"id":66153293,"uuid":"90196206","full_name":"documentationjs/zeroarg","owner":"documentationjs","description":"disappearing argument parser","archived":false,"fork":false,"pushed_at":"2017-05-04T21:11:14.000Z","size":174,"stargazers_count":19,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-01T14:56:56.313Z","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/documentationjs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-03T21:47:05.000Z","updated_at":"2022-11-02T13:55:35.000Z","dependencies_parsed_at":"2023-05-09T20:17:43.404Z","dependency_job_id":null,"html_url":"https://github.com/documentationjs/zeroarg","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/documentationjs%2Fzeroarg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/documentationjs%2Fzeroarg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/documentationjs%2Fzeroarg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/documentationjs%2Fzeroarg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/documentationjs","download_url":"https://codeload.github.com/documentationjs/zeroarg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250110898,"owners_count":21376551,"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-09T19:33:18.356Z","updated_at":"2025-04-21T18:31:13.410Z","avatar_url":"https://github.com/documentationjs.png","language":"JavaScript","readme":"# zeroarg\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./.github/logo.jpg\" width=\"250\" height=\"250\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  disappearing argument parser\n\u003c/p\u003e\n\nThis is admittedly a little :microscope: mad science. The gist is that zeroarg\nis an argument parser, with [yargs](https://github.com/yargs/yargs) at its\ncore, that doesn't require you to touch yargs, or argument-parsing specifics.\nIt aims to infer types and reuse documentation to do that.\n\nHere's an example CLI written with zeroarg:\n\n```js\nvar zeroarg = require('zeroarg');\n\nzeroarg(() =\u003e\n  /**\n   * Add numbers together\n   * @param {Array\u003cnumber\u003e} numbers\n   */\n  function add(numbers) {\n    console.log(numbers.reduce((sum, num) =\u003e sum + num, 0));\n  }\n);\n```\n\nThis produces proper help material:\n\n```js\nCommands:\n  run [numbers..]\n\nOptions:\n  --help  Show help     [boolean]\n\nAdd numbers together\n```\n\nAnd adds numbers together when you run it:\n\n```js\n$ ./examples/add.js run 1 2 3 4\n10\n```\n\n## Why?\n\n-   Argument parsing still feels like a source of uncertainty in programming: it's like\n    the same as parsing query arguments, except for the CLI: you're getting who knows what\n    from who knows who. Your program has types and expectations - maybe even official types\n    with Flowtype - and yet argument parsers make you redeclare those types, or even\n    allow untyped, unexpected input. What if argument parsers leveraged your program's\n    existing assumptions and treated CLIs more like functions?\n-   It's possibly a little less code to write, and one less API to learn! zeroarg's\n    API surface is one function, and it uses existing standards (JSDoc \u0026 Flow)\n    to express assumptions about argument types.\n-   It's super fun and weird.\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n## zeroarg\n\nzeroarg a code-free argument parser\n\nFunctions that you provide to zeroarg follow certain rules:\n\nTheir arguments work like:\n\n    [positionalArgument],\n    [positionalArgument2],\n    [variadicPositionalArgument],\n    [optionsArgument]\n\n-   The first arguments can be positional arguments.\n-   The last argument to the method can be an object that receives the\n    flag arguments (like --option). Only the last argument can be an options\n    object.\n    -   Options can have JSDoc types of string, number, array, and boolean.\n    -   If you specify a default in JSDoc-land, it becomes a default in yargs\n    -   If you specify an argument as an enum in JSDoc-land, it becomes choices in yargs\n\n**Parameters**\n\n-   `fn` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a function that returns a function, and has at least\n    one JSDoc comment preceding that function.\n\n**Examples**\n\n```javascript\nzeroarg(() =\u003e\n /**\n  * Hello world\n  *\\/\n function helloworld() {\n   console.log('Hello world');\n }\n);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocumentationjs%2Fzeroarg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdocumentationjs%2Fzeroarg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocumentationjs%2Fzeroarg/lists"}