{"id":24845898,"url":"https://github.com/oorabona/reargs-cli","last_synced_at":"2026-05-03T19:33:30.993Z","repository":{"id":40311412,"uuid":"372046004","full_name":"oorabona/reargs-cli","owner":"oorabona","description":"A CLI tool to help creating and validating argument parsing with [reargs](https://github.com/oorabona/reargs)","archived":false,"fork":false,"pushed_at":"2023-03-06T03:37:04.000Z","size":640,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T08:48:14.542Z","etag":null,"topics":["argument","cli","nodejs","parsing","reargs"],"latest_commit_sha":null,"homepage":"","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/oorabona.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":"2021-05-29T18:36:33.000Z","updated_at":"2021-06-06T17:21:19.000Z","dependencies_parsed_at":"2025-03-26T08:45:33.548Z","dependency_job_id":"394cced8-1f41-4020-9dd8-2d64c48df967","html_url":"https://github.com/oorabona/reargs-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oorabona/reargs-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oorabona%2Freargs-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oorabona%2Freargs-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oorabona%2Freargs-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oorabona%2Freargs-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oorabona","download_url":"https://codeload.github.com/oorabona/reargs-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oorabona%2Freargs-cli/sbom","scorecard":{"id":708035,"data":{"date":"2025-08-11","repo":{"name":"github.com/oorabona/reargs-cli","commit":"5739f3c31d6c69bd595d7eb7968df4471459f3de"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/8 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"21 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-x77j-w7wf-fjmw","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T07:18:00.272Z","repository_id":40311412,"created_at":"2025-08-22T07:18:00.273Z","updated_at":"2025-08-22T07:18:00.273Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["argument","cli","nodejs","parsing","reargs"],"created_at":"2025-01-31T10:17:15.256Z","updated_at":"2026-05-03T19:33:30.976Z","avatar_url":"https://github.com/oorabona.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reargs-cli - A CLI tool to help create and validate argument parsing with Reargs\n\nThis is both a helper for your (daily !) usage of [Reargs](https://github.com/oorabona/reargs) and also a showcase since it serves as a quite complete example of its usage.\n\nBasically this program takes an input file (or stdin) and try its best to gather the command line parameters, `short` and `long` versions, `help` and if told so it can also prepare the Regular Expressions to match.\n\nLet's see!\n\n\u003e **NOTE**\n\u003e You can find all the examples in the [examples](examples/) directory.\n\n## An example: **grep**\n\nSo imagine you want to create a `grep` clone in `NodeJS` :rocket:\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to show a typical output of `grep --help`\u003c/summary\u003e\n\u003cp\u003e\n\n```sh\n$ grep --help\nUsage: grep [OPTION]... PATTERNS [FILE]...\nSearch for PATTERNS in each FILE.\nExample: grep -i 'hello world' menu.h main.c\nPATTERNS can contain multiple patterns separated by newlines.\n\nPattern selection and interpretation:\n  -E, --extended-regexp     PATTERNS are extended regular expressions\n  -F, --fixed-strings       PATTERNS are strings\n  -G, --basic-regexp        PATTERNS are basic regular expressions\n  -P, --perl-regexp         PATTERNS are Perl regular expressions\n  -e, --regexp=PATTERNS     use PATTERNS for matching\n  -f, --file=FILE           take PATTERNS from FILE\n  -i, --ignore-case         ignore case distinctions in patterns and data\n      --no-ignore-case      do not ignore case distinctions (default)\n  -w, --word-regexp         match only whole words\n  -x, --line-regexp         match only whole lines\n  -z, --null-data           a data line ends in 0 byte, not newline\n\nMiscellaneous:\n  -s, --no-messages         suppress error messages\n  -v, --invert-match        select non-matching lines\n  -V, --version             display version information and exit\n      --help                display this help text and exit\n\nOutput control:\n  -m, --max-count=NUM       stop after NUM selected lines\n  -b, --byte-offset         print the byte offset with output lines\n  -n, --line-number         print line number with output lines\n      --line-buffered       flush output on every line\n  -H, --with-filename       print file name with output lines\n  -h, --no-filename         suppress the file name prefix on output\n      --label=LABEL         use LABEL as the standard input file name prefix\n  -o, --only-matching       show only nonempty parts of lines that match\n  -q, --quiet, --silent     suppress all normal output\n      --binary-files=TYPE   assume that binary files are TYPE;\n                            TYPE is 'binary', 'text', or 'without-match'\n  -a, --text                equivalent to --binary-files=text\n  -I                        equivalent to --binary-files=without-match\n  -d, --directories=ACTION  how to handle directories;\n                            ACTION is 'read', 'recurse', or 'skip'\n  -D, --devices=ACTION      how to handle devices, FIFOs and sockets;\n                            ACTION is 'read' or 'skip'\n  -r, --recursive           like --directories=recurse\n  -R, --dereference-recursive  likewise, but follow all symlinks\n      --include=GLOB        search only files that match GLOB (a file pattern)\n      --exclude=GLOB        skip files that match GLOB\n      --exclude-from=FILE   skip files that match any file pattern from FILE\n      --exclude-dir=GLOB    skip directories that match GLOB\n  -L, --files-without-match  print only names of FILEs with no selected lines\n  -l, --files-with-matches  print only names of FILEs with selected lines\n  -c, --count               print only a count of selected lines per FILE\n  -T, --initial-tab         make tabs line up (if needed)\n  -Z, --null                print 0 byte after FILE name\n\nContext control:\n  -B, --before-context=NUM  print NUM lines of leading context\n  -A, --after-context=NUM   print NUM lines of trailing context\n  -C, --context=NUM         print NUM lines of output context\n  -NUM                      same as --context=NUM\n      --color[=WHEN],\n      --colour[=WHEN]       use markers to highlight the matching strings;\n                            WHEN is 'always', 'never', or 'auto'\n  -U, --binary              do not strip CR characters at EOL (MSDOS/Windows)\n\nWhen FILE is '-', read standard input.  With no FILE, read '.' if\nrecursive, '-' otherwise.  With fewer than two FILEs, assume -h.\nExit status is 0 if any line is selected, 1 otherwise;\nif any error occurs and -q is not given, the exit status is 2.\n\nReport bugs to: bug-grep@gnu.org\nGNU grep home page: \u003chttp://www.gnu.org/software/grep/\u003e\nGeneral help using GNU software: \u003chttps://www.gnu.org/gethelp/\u003e\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n### Basic usage\n\nThe default parser (a regular expression of course) can handle parsing this typical help with this simple command below\n\n```sh\n$ grep --help | reargs -r\n```\n\n\u003e Note: `-r` here removes undefined attributes (like if there is no short parameter, do not output it).\n\n\u003cdetails\u003e\n\u003csummary\u003eClick here to see the output\u003c/summary\u003e\n\u003cp\u003e\n\n```js\nexports = {\n  extendedregexp: {\n    short: '-E',\n    long: '--extended-regexp',\n    humanReadable: '-E, --extended-regexp',\n    help: 'PATTERNS are extended regular expressions'\n  },\n  fixedstrings: {\n    short: '-F',\n    long: '--fixed-strings',\n    humanReadable: '-F, --fixed-strings',\n    help: 'PATTERNS are strings'\n  },\n  basicregexp: {\n    short: '-G',\n    long: '--basic-regexp',\n    humanReadable: '-G, --basic-regexp',\n    help: 'PATTERNS are basic regular expressions'\n  },\n  perlregexp: {\n    short: '-P',\n    long: '--perl-regexp',\n    humanReadable: '-P, --perl-regexp',\n    help: 'PATTERNS are Perl regular expressions'\n  },\n  regexpPATTERNS: {\n    short: '-e[^\\\\ ]+',\n    long: '--regexp=[^\\\\ ]+',\n    humanReadable: '-e, --regexp=PATTERNS',\n    help: 'use PATTERNS for matching'\n  },\n  fileFILE: {\n    short: '-f[^\\\\ ]+',\n    long: '--file=[^\\\\ ]+',\n    humanReadable: '-f, --file=FILE',\n    help: 'take PATTERNS from FILE'\n  },\n  ignorecase: {\n    short: '-i',\n    long: '--ignore-case',\n    humanReadable: '-i, --ignore-case',\n    help: 'ignore case distinctions in patterns and data'\n  },\n  noignorecase: {\n    long: '--no-ignore-case',\n    humanReadable: '--no-ignore-case',\n    help: 'do not ignore case distinctions (default)'\n  },\n  wordregexp: {\n    short: '-w',\n    long: '--word-regexp',\n    humanReadable: '-w, --word-regexp',\n    help: 'match only whole words'\n  },\n  lineregexp: {\n    short: '-x',\n    long: '--line-regexp',\n    humanReadable: '-x, --line-regexp',\n    help: 'match only whole lines'\n  },\n  nulldata: {\n    short: '-z',\n    long: '--null-data',\n    humanReadable: '-z, --null-data',\n    help: 'a data line ends in 0 byte, not newline'\n  },\n  nomessages: {\n    short: '-s',\n    long: '--no-messages',\n    humanReadable: '-s, --no-messages',\n    help: 'suppress error messages'\n  },\n  invertmatch: {\n    short: '-v',\n    long: '--invert-match',\n    humanReadable: '-v, --invert-match',\n    help: 'select non-matching lines'\n  },\n  version: {\n    short: '-V',\n    long: '--version',\n    humanReadable: '-V, --version',\n    help: 'display version information and exit'\n  },\n  help: {\n    long: '--help',\n    humanReadable: '--help',\n    help: 'display this help text and exit'\n  },\n  maxcountNUM: {\n    short: '-m[^\\\\ ]+',\n    long: '--max-count=[^\\\\ ]+',\n    humanReadable: '-m, --max-count=NUM',\n    help: 'stop after NUM selected lines'\n  },\n  byteoffset: {\n    short: '-b',\n    long: '--byte-offset',\n    humanReadable: '-b, --byte-offset',\n    help: 'print the byte offset with output lines'\n  },\n  linenumber: {\n    short: '-n',\n    long: '--line-number',\n    humanReadable: '-n, --line-number',\n    help: 'print line number with output lines'\n  },\n  linebuffered: {\n    long: '--line-buffered',\n    humanReadable: '--line-buffered',\n    help: 'flush output on every line'\n  },\n  withfilename: {\n    short: '-H',\n    long: '--with-filename',\n    humanReadable: '-H, --with-filename',\n    help: 'print file name with output lines'\n  },\n  nofilename: {\n    short: '-h',\n    long: '--no-filename',\n    humanReadable: '-h, --no-filename',\n    help: 'suppress the file name prefix on output'\n  },\n  labelLABEL: {\n    long: '--label=[^\\\\ ]+',\n    humanReadable: '--label=LABEL',\n    help: 'use LABEL as the standard input file name prefix'\n  },\n  onlymatching: {\n    short: '-o',\n    long: '--only-matching',\n    humanReadable: '-o, --only-matching',\n    help: 'show only nonempty parts of lines that match'\n  },\n  silent: {\n    short: '-q',\n    long: '--silent',\n    humanReadable: '-q, --silent',\n    help: 'suppress all normal output'\n  },\n  binaryfilesTYPE: {\n    long: '--binary-files=[^\\\\ ]+',\n    humanReadable: '--binary-files=TYPE',\n    help: 'assume that binary files are TYPE;'\n  },\n  param: {\n    humanReadable: '',\n    help: \"TYPE is 'binary', 'text', or 'without-match'\"\n  },\n  text: {\n    short: '-a',\n    long: '--text',\n    humanReadable: '-a, --text',\n    help: 'equivalent to --binary-files=text'\n  },\n  I: {\n    short: '-I',\n    humanReadable: '-I',\n    help: 'equivalent to --binary-files=without-match'\n  },\n  directoriesACTION: {\n    short: '-d[^\\\\ ]+',\n    long: '--directories=[^\\\\ ]+',\n    humanReadable: '-d, --directories=ACTION',\n    help: 'how to handle directories;\\n' +\n      \"                            ACTION is 'read', 'recurse', or 'skip'\"\n  },\n  devicesACTION: {\n    short: '-D[^\\\\ ]+',\n    long: '--devices=[^\\\\ ]+',\n    humanReadable: '-D, --devices=ACTION',\n    help: 'how to handle devices, FIFOs and sockets;\\n' +\n      \"                            ACTION is 'read' or 'skip'\"\n  },\n  recursive: {\n    short: '-r',\n    long: '--recursive',\n    humanReadable: '-r, --recursive',\n    help: 'like --directories=recurse'\n  },\n  dereferencerecursive: {\n    short: '-R',\n    long: '--dereference-recursive',\n    humanReadable: '-R, --dereference-recursive',\n    help: 'likewise, but follow all symlinks'\n  },\n  includeGLOB: {\n    long: '--include=[^\\\\ ]+',\n    humanReadable: '--include=GLOB',\n    help: 'search only files that match GLOB (a file pattern)'\n  },\n  excludeGLOB: {\n    long: '--exclude=[^\\\\ ]+',\n    humanReadable: '--exclude=GLOB',\n    help: 'skip files that match GLOB'\n  },\n  excludefromFILE: {\n    long: '--exclude-from=[^\\\\ ]+',\n    humanReadable: '--exclude-from=FILE',\n    help: 'skip files that match any file pattern from FILE'\n  },\n  excludedirGLOB: {\n    long: '--exclude-dir=[^\\\\ ]+',\n    humanReadable: '--exclude-dir=GLOB',\n    help: 'skip directories that match GLOB'\n  },\n  fileswithoutmatch: {\n    short: '-L',\n    long: '--files-without-match',\n    humanReadable: '-L, --files-without-match',\n    help: 'print only names of FILEs with no selected lines'\n  },\n  fileswithmatches: {\n    short: '-l',\n    long: '--files-with-matches',\n    humanReadable: '-l, --files-with-matches',\n    help: 'print only names of FILEs with selected lines'\n  },\n  count: {\n    short: '-c',\n    long: '--count',\n    humanReadable: '-c, --count',\n    help: 'print only a count of selected lines per FILE'\n  },\n  initialtab: {\n    short: '-T',\n    long: '--initial-tab',\n    humanReadable: '-T, --initial-tab',\n    help: 'make tabs line up (if needed)'\n  },\n  null: {\n    short: '-Z',\n    long: '--null',\n    humanReadable: '-Z, --null',\n    help: 'print 0 byte after FILE name'\n  },\n  beforecontextNUM: {\n    short: '-B[^\\\\ ]+',\n    long: '--before-context=[^\\\\ ]+',\n    humanReadable: '-B, --before-context=NUM',\n    help: 'print NUM lines of leading context'\n  },\n  aftercontextNUM: {\n    short: '-A[^\\\\ ]+',\n    long: '--after-context=[^\\\\ ]+',\n    humanReadable: '-A, --after-context=NUM',\n    help: 'print NUM lines of trailing context'\n  },\n  contextNUM: {\n    short: '-C[^\\\\ ]+',\n    long: '--context=[^\\\\ ]+',\n    humanReadable: '-C, --context=NUM',\n    help: 'print NUM lines of output context'\n  },\n  NUM: {\n    short: '-NUM',\n    humanReadable: '-NUM',\n    help: 'same as --context=NUM'\n  },\n  colorWHEN: {\n    long: '--color[=WHEN]',\n    humanReadable: '--color[=WHEN]',\n    help: ','\n  },\n  colourWHEN: {\n    long: '--colour[=WHEN]',\n    humanReadable: '--colour[=WHEN]',\n    help: 'use markers to highlight the matching strings;\\n' +\n      \"                            WHEN is 'always', 'never', or 'auto'\"\n  },\n  binary: {\n    short: '-U',\n    long: '--binary',\n    humanReadable: '-U, --binary',\n    help: 'do not strip CR characters at EOL (MSDOS/Windows)'\n  }\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\nAs you can see, the default output here is a typical `Javascript` content, you could just copy/paste.\n\nYou can also just `require` if you want :wink:\n\n\u003e **Note**\n\u003e In the above output, there is a parameter called `param`.\n\n```js\nparam: {\n  humanReadable: '',\n  help: \"TYPE is 'binary', 'text', or 'without-match'\"\n},\n```\n\nThis parameter is invalid and will not be accepted when instantiating `Reargs` afterwards.\n\nThis is because the default RegExp is not perfect (and you can help me find a better suited one, feel free to PR !) and sometimes there are leftovers.\n\nThis is why you should always test what is produced by this tool, and we will get to that later on in this README.\n\n### Changing output format\n\nIf you want to change the output, you have two other options :\n\n* `json` for a minified JSON\n* `pretty` for a prettyfied JSON\n\nYou can select using the `-o` option like :\n\n```sh\n$ grep --help | reargs -r -o json\n```\n\nBut that is not all !\n\n### Replacing parameter attribute with a customized RegExp\n\nAs you can see, there are several parameters having custom attributes, like `--context` or `--color`. So at some point we might want to specify the `RegExp` you want to map with these attributes.\n\nBy default `reargs` replaces every time there is a match with an attribute in CAPITAL letters with a default RegExp matching everything till the next space it founds.\n\nYou can change this behavior by setting the `-da=\"\u003cyour_own_regexp\u003e\"`.\n\nOf course you can do it separately by finding/replacing in your favorite text editor, and if you do not want this, you just need to pass the `-nda` (or `--no-default-attribute` parameter).\n\nIf you want to do it using this tool, you can for instance :\n\n```sh\n$ grep --help | reargs -r -a NUM=\"[0-9]+\"\n```\n\nWill replace each occurrence of **NUM** with this RegExp.\n\nA more complete example would be like this one :\n\n```sh\n$ grep --help | reargs -r -a WHEN=\"(always|never|auto)\",NUM=\"[0-9]+\" -a ACTION=\"(read|recurse|skip)\"\n```\n\n\u003e **Note**\n\u003e Double quotes might not be necessary, it depends on your shell and how it handles these special characters (i.e. `[]` and `()`).\n\nWe can go a bit further by trying to *convert* some remarkable patterns to help designing the required RegExp.\n\nFor instance, let's take the parameter :\n\n```\n--color[=WHEN]\n```\n\nIt can be interpreted as an optional attribute leaving `--color` as a possible acceptable input.\n\nNow if you enable the switch `-c` (or `--convert`), then this parameter will have the following definition :\n\n```js\n{\n  colourWHEN: {\n    long: '--colour=?(?\u003cWHEN\u003e(always|never|auto))?',\n    humanReadable: '--colour[=WHEN]',\n    help: 'use markers to highlight the matching strings;\\n' +\n      \"                            WHEN is 'always', 'never', or 'auto'\"\n  },\n}\n```\n\nPretty cool huh ? :wink:\n\n### Using a different PATTERN to match\n\nThis tool is unfortunately not magic, or the magic happens thanks to a well written and battle tested Regular Expression.\n\nAt the moment the one that gives best result is this one :\n\n```js\n/^\\ +(?\u003cshort\u003e-[^-,\\ ]+(?:\\ [\u003c\\[]\\w+[\u003e\\]])?)*(,?\\ ?(?\u003clong\u003e--[^,\\ ]+),?)*\\ +(?\u003chelp\u003e[^\\n]+(?:\\n[^-\\n]+$)*)/gm\n```\n\nBut sometimes it leaves some work to be done.\n\nIf you feel like doing some RegExp testing against your own patterns, you can use the following command, e.g. :\n\n```sh\n$ grep --help | reargs -r -p patterns.json\n```\n\nThe file must be a JSON, a typical one would be :\n\n```js\n[\n  \"^\\ +(?\u003cshort\u003e-[^-,\\ ]+(?:\\ [\u003c\\[]\\w+[\u003e\\]])?)*(,?\\ ?(?\u003clong\u003e--[^,\\ ]+),?)*\\ +(?\u003chelp\u003e[^\\n]+(?:\\n[^-\\n]+$)*)\",\n]\n```\n\nMeaning an `Array` of `string`s being `RegExp`s.\n\nEach one will be tested and the **best** one will serve as output.\n\nSo how do we know which one is the __best__ one ?\n\nInternally, there is an object maintaining all computed parameter names, if they are found. These parameter names are built from either `short` or `long` discovered patterns. If none can be found, a default `param` is used.\n\nThe idea is therefore to minimize the number of undiscovered parameters :unicorn: each time by parsing the whole input.\n\n## Generating help\n\nOnce you have your `JSON` or Plain `Javascript` source file, you can test outputting a typical `help` using `generateHelp` API from [Reargs](https://github.com/oorabona/reargs).\n\nTo do that, simply try this command :\n\n```sh\n$ reargs -f examples/grep.json gen help\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eClick here to show the typical (default template) generated help\u003c/summary\u003e\n\u003cp\u003e\n\n```sh\nYour app v0.0.0 - This description needs to be customized ! - by John Doe\n\nUsage:\n  Your app [_]\n\n\n_s:\n\n  -E, --extended-regexp         PATTERNS are extended regular expressions\n  -F, --fixed-strings           PATTERNS are strings\n  -G, --basic-regexp            PATTERNS are basic regular expressions\n  -P, --perl-regexp             PATTERNS are Perl regular expressions\n  -e, --regexp=PATTERNS         use PATTERNS for matching\n  -f, --file=FILE               take PATTERNS from FILE\n  -i, --ignore-case             ignore case distinctions in patterns and data\n      --no-ignore-case          do not ignore case distinctions (default)\n  -w, --word-regexp             match only whole words\n  -x, --line-regexp             match only whole lines\n  -z, --null-data               a data line ends in 0 byte, not newline\n  -s, --no-messages             suppress error messages\n  -v, --invert-match            select non-matching lines\n  -V, --version                 display version information and exit\n      --help                    display this help text and exit\n  -m, --max-count=NUM           stop after NUM selected lines\n  -b, --byte-offset             print the byte offset with output lines\n  -n, --line-number             print line number with output lines\n      --line-buffered           flush output on every line\n  -H, --with-filename           print file name with output lines\n  -h, --no-filename             suppress the file name prefix on output\n      --label=LABEL             use LABEL as the standard input file name prefix\n  -o, --only-matching           show only nonempty parts of lines that match\n  -q, --silent                  suppress all normal output\n      --binary-files=TYPE       assume that binary files are TYPE; TYPE is \u0026#39;binary\u0026#39;, \u0026#39;text\u0026#39;, or \u0026#39;without-match\u0026#39;\n  -a, --text                    equivalent to --binary-files=text\n  -I                            equivalent to --binary-files=without-match\n  -d, --directories=ACTION      how to handle directories;\n                            ACTION is \u0026#39;read\u0026#39;, \u0026#39;recurse\u0026#39;, or \u0026#39;skip\u0026#39;\n  -D, --devices=ACTION          how to handle devices, FIFOs and sockets;\n                            ACTION is \u0026#39;read\u0026#39; or \u0026#39;skip\u0026#39;\n  -r, --recursive               like --directories=recurse\n  -R, --dereference-recursive   likewise, but follow all symlinks\n      --include=GLOB            search only files that match GLOB (a file pattern)\n      --exclude=GLOB            skip files that match GLOB\n      --exclude-from=FILE       skip files that match any file pattern from FILE\n      --exclude-dir=GLOB        skip directories that match GLOB\n  -L, --files-without-match     print only names of FILEs with no selected lines\n  -l, --files-with-matches      print only names of FILEs with selected lines\n  -c, --count                   print only a count of selected lines per FILE\n  -T, --initial-tab             make tabs line up (if needed)\n  -Z, --null                    print 0 byte after FILE name\n  -B, --before-context=NUM      print NUM lines of leading context\n  -A, --after-context=NUM       print NUM lines of trailing context\n  -C, --context=NUM             print NUM lines of output context\n  -NUM                          same as --context=NUM\n      --color[=WHEN]            ,\n      --colour[=WHEN]           use markers to highlight the matching strings;\n                            WHEN is \u0026#39;always\u0026#39;, \u0026#39;never\u0026#39;, or \u0026#39;auto\u0026#39;\n  -U, --binary                  do not strip CR characters at EOL (MSDOS/Windows)\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003e **NOTE**\n\u003e You can see escaped characters (e.g. `\u0026#39`) because by default the template force output to be safe. And single quotes are not _safe_ per se.\n\nNow if you want to customize this, simply create a template file, following [nunjucks](https://mozilla.github.io/nunjucks) templating capabilities.\n\nOnce you have your file, for example this [one](examples/grep.tpl), you can try it with :\n\n```sh\n$ reargs -f examples/grep.json -t examples/grep.tpl gen help\n```\n\nAnd see that autogenerated output :heart_eyes: :\n\n\u003cdetails\u003e\n\u003csummary\u003eClick here to show\u003c/summary\u003e\n\u003cp\u003e\n\n```sh\nUsage: grep [OPTION]... PATTERNS [FILE]...\nSearch for PATTERNS in each FILE.\nExample: grep -i 'hello world' menu.h main.c\nPATTERNS can contain multiple patterns separated by newlines.\n\nOPTIONS:\n\n\n  -E, --extended-regexp         PATTERNS are extended regular expressions\n  -F, --fixed-strings           PATTERNS are strings\n  -G, --basic-regexp            PATTERNS are basic regular expressions\n  -P, --perl-regexp             PATTERNS are Perl regular expressions\n  -e, --regexp=PATTERNS         use PATTERNS for matching\n  -f, --file=FILE               take PATTERNS from FILE\n  -i, --ignore-case             ignore case distinctions in patterns and data\n      --no-ignore-case          do not ignore case distinctions (default)\n  -w, --word-regexp             match only whole words\n  -x, --line-regexp             match only whole lines\n  -z, --null-data               a data line ends in 0 byte, not newline\n  -s, --no-messages             suppress error messages\n  -v, --invert-match            select non-matching lines\n  -V, --version                 display version information and exit\n      --help                    display this help text and exit\n  -m, --max-count=NUM           stop after NUM selected lines\n  -b, --byte-offset             print the byte offset with output lines\n  -n, --line-number             print line number with output lines\n      --line-buffered           flush output on every line\n  -H, --with-filename           print file name with output lines\n  -h, --no-filename             suppress the file name prefix on output\n      --label=LABEL             use LABEL as the standard input file name prefix\n  -o, --only-matching           show only nonempty parts of lines that match\n  -q, --silent                  suppress all normal output\n      --binary-files=TYPE       assume that binary files are TYPE; TYPE is \u0026#39;binary\u0026#39;, \u0026#39;text\u0026#39;, or \u0026#39;without-match\u0026#39;\n  -a, --text                    equivalent to --binary-files=text\n  -I                            equivalent to --binary-files=without-match\n  -d, --directories=ACTION      how to handle directories;\n                            ACTION is \u0026#39;read\u0026#39;, \u0026#39;recurse\u0026#39;, or \u0026#39;skip\u0026#39;\n  -D, --devices=ACTION          how to handle devices, FIFOs and sockets;\n                            ACTION is \u0026#39;read\u0026#39; or \u0026#39;skip\u0026#39;\n  -r, --recursive               like --directories=recurse\n  -R, --dereference-recursive   likewise, but follow all symlinks\n      --include=GLOB            search only files that match GLOB (a file pattern)\n      --exclude=GLOB            skip files that match GLOB\n      --exclude-from=FILE       skip files that match any file pattern from FILE\n      --exclude-dir=GLOB        skip directories that match GLOB\n  -L, --files-without-match     print only names of FILEs with no selected lines\n  -l, --files-with-matches      print only names of FILEs with selected lines\n  -c, --count                   print only a count of selected lines per FILE\n  -T, --initial-tab             make tabs line up (if needed)\n  -Z, --null                    print 0 byte after FILE name\n  -B, --before-context=NUM      print NUM lines of leading context\n  -A, --after-context=NUM       print NUM lines of trailing context\n  -C, --context=NUM             print NUM lines of output context\n  -NUM                          same as --context=NUM\n      --color[=WHEN]            ,\n      --colour[=WHEN]           use markers to highlight the matching strings;\n                            WHEN is \u0026#39;always\u0026#39;, \u0026#39;never\u0026#39;, or \u0026#39;auto\u0026#39;\n  -U, --binary                  do not strip CR characters at EOL (MSDOS/Windows)\n\n\nWhen FILE is '-', read standard input.  With no FILE, read '.' if\nrecursive, '-' otherwise.  With fewer than two FILEs, assume -h.\nExit status is 0 if any line is selected, 1 otherwise;\nif any error occurs and -q is not given, the exit status is 2.\n\nReport bugs to: bug-grep@gnu.org\nGNU grep home page: \u003chttp://www.gnu.org/software/grep/\u003e\nGeneral help using GNU software: \u003chttps://www.gnu.org/gethelp/\u003e\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\nYay ! We are almost there. Feel free to play with this template engine to fit it to your needs.\n\n### Testing\n\nMore important is to make sure your configuration is correct before even going to test in your own program.\n\nTo help you succesfully achieve that, you can use `test` command, and pass the command line parameters after `--` like in the example below:\n\n```sh\n$ reargs -f examples/grep.json test -- -z --help -U -34 -I\nunparsable\nvalues {\n  extendedregexp: false,\n  fixedstrings: false,\n  basicregexp: false,\n  perlregexp: false,\n  regexpPATTERNS: false,\n  fileFILE: false,\n  ignorecase: false,\n  noignorecase: false,\n  wordregexp: false,\n  lineregexp: false,\n  nulldata: true,\n  nomessages: false,\n  invertmatch: false,\n  version: false,\n  help: true,\n  maxcountNUM: false,\n  byteoffset: false,\n  linenumber: false,\n  linebuffered: false,\n  withfilename: false,\n  nofilename: false,\n  labelLABEL: false,\n  onlymatching: false,\n  silent: false,\n  binaryfilesTYPE: false,\n  text: false,\n  I: true,\n  directoriesACTION: false,\n  devicesACTION: false,\n  recursive: false,\n  dereferencerecursive: false,\n  includeGLOB: false,\n  excludeGLOB: false,\n  excludefromFILE: false,\n  excludedirGLOB: false,\n  fileswithoutmatch: false,\n  fileswithmatches: false,\n  count: false,\n  initialtab: false,\n  null: false,\n  beforecontextNUM: false,\n  aftercontextNUM: false,\n  contextNUM: false,\n  NUM: '34',\n  colorWHEN: false,\n  colourWHEN: false,\n  binary: true\n}\n```\n\nAnd you can play with it knowing that it will also support if you have `--` in your accepted parameters ! :wink:\n\n## Contributing\n\nLicence is [MIT](LICENSE), feel free to raise issues, provide PR or just drop a word about how you use it, what would be the next features you would like this piece of software to have.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foorabona%2Freargs-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foorabona%2Freargs-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foorabona%2Freargs-cli/lists"}