{"id":24818689,"url":"https://github.com/cmames/argjson","last_synced_at":"2026-02-16T20:33:33.581Z","repository":{"id":57183534,"uuid":"431524944","full_name":"cmames/argjson","owner":"cmames","description":"argv parser for node.js","archived":false,"fork":false,"pushed_at":"2025-03-05T08:04:36.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T20:32:21.192Z","etag":null,"topics":["argument-parser","arguments","cli","command-line","module","node","node-js","nodejs","parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmames.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,"zenodo":null}},"created_at":"2021-11-24T14:56:52.000Z","updated_at":"2025-03-05T08:04:39.000Z","dependencies_parsed_at":"2025-03-14T11:04:24.646Z","dependency_job_id":"51a8e44c-7c48-4e75-94c9-a93e1a1b5251","html_url":"https://github.com/cmames/argjson","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/cmames/argjson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmames%2Fargjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmames%2Fargjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmames%2Fargjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmames%2Fargjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmames","download_url":"https://codeload.github.com/cmames/argjson/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmames%2Fargjson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29517613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T18:37:19.720Z","status":"ssl_error","status_checked_at":"2026-02-16T18:36:46.920Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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-parser","arguments","cli","command-line","module","node","node-js","nodejs","parser"],"created_at":"2025-01-30T17:37:21.866Z","updated_at":"2026-02-16T20:33:33.555Z","avatar_url":"https://github.com/cmames.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# argjson\n\n[![npm version](https://badge.fury.io/js/argjson.svg?kill_cache=1)](https://badge.fury.io/js/argjson.svg)\n[![GitHub license](https://img.shields.io/github/license/cmames/argjson)](https://github.com/cmames/argjson/blob/main/LICENSE)\n![GitHub last commit](https://img.shields.io/github/last-commit/cmames/argjson)\n\n![GitHub top language](https://img.shields.io/github/languages/top/cmames/argjson)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/cmames/argjson)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/cmames/argjson)\n\n\n:uk: an argument parser for node.js \n\u003e :fr: un parser d'arguments pour node.js.\n\n\u003ca href=\"https://github.com/cmames/argjson\"\u003ehttps://github.com/cmames/argjson\u003c/a\u003e\n\n---\n### Why\n\nit's always useful and avoids having to code everything according to the types and number of arguments.\n\n\u003e ### Pourquoi\n\u003e\n\u003e c'est toujours utile et ça évite d'avoir à tout coder en fonction des types et du nombre d'argument.\n\n---\n### Installation\n```\nnpm install argjson\n```\n\u003e ### Installation\n\u003e ```\n\u003e npm install argjson\n\u003e ```\n\n---\n### Usage\n\nimport the package in your node file\n```\nconst argjson=require(\"argjson\");\n```\ncreate your menu options by calling the add method\n```\nargjson.add({\n        arg: \"file\",\n        short: \"f\",\n        description: \"file to open\",\n        default:\"\"\n});\n```\narg : the name of the argument\n\nshort : the short name of the argument\n\ndescription : the description of the argument\n\ndefault : the default value of the argument\n\n\nIn the previous example we created the argument --file or -f \n\nFor on/off arguments like verbose we can do\n```\nargjson.add({\n        arg: \"verbose\",\n        short: \"v\",\n        description: \"verbose mode\",\n        default:false\n});\n```\nin this case and only in this case default is optional and we have created --verbose or -v\n\n-v will be different from -V\n\nthe --help or -h argument is already defined by default and displays the help\n\nyou can concatenate the short arguments \n\n-a -b -c is equivalent to -abc\n-a -b -c -f myfile is equivalent to -abcf myfile\n\nyou can pass arrays and json as arguments\n```\nargjson.add({\n        arg: \"tab\",\n        short: \"t\",\n        description: \"array\",\n        default:[]\n});\nargjson.add({\n        arg: \"json\",\n        short: \"j\",\n        description: \"json\",\n        default:{}\n});\n```\nor\n```\nargjson.add(...).add(...).add(...).add(...)\n```\nonce the arguments are defined, you just have to launch the parser\n```\nvar argv=argjson.parse();\n```\nthen you find in argv all the arguments with their long name\n```\nargv.file\nargv.verbose\nargv.tab\nargv.json\n```\nthe syntax argv[\"file\"] also works\n\nexample of use\n```\nnode myfile.js --file test.txt --tab \"[1, 3, 5, 42]\" --size 1024 --factor 1.27 -vxc\n```\n\n\u003e Utilisation\n\u003e \n\u003e importez le paquet dans votre fichier node\n\u003e ```\n\u003e const argjson=require(\"argjson\");\n\u003e ```\n\u003e créez vos option de menu en appelant la méthode add\n\u003e ```\n\u003e argjson.add({\n\u003e         arg: \"file\",\n\u003e         short:\"f\",\n\u003e         description:\"file to open\",\n\u003e         default:\"\"\n\u003e });\n\u003e ```\n\u003e arg : le nom de l'argument\n\u003e \n\u003e short : le nom court de l'argument\n\u003e \n\u003e description : la description de l'argument\n\u003e \n\u003e default : la valeur par défaut de l'argument\n\u003e \n\u003e Dans l'exemple précédent on a créé l'argument --file ou -f \n\u003e \n\u003e Pour des arguments on/off comme verbose on peut faire\n\u003e ```\n\u003e argjson.add({\n\u003e         arg: \"verbose\",\n\u003e         short:\"v\",\n\u003e         description:\"verbose mode\",\n\u003e         default:false\n\u003e });\n\u003e ```\n\u003e dans ce cas et seulement dans ce cas default est facultatif et on a créé --verbose ou -v\n\u003e \n\u003e -v sera différent de -V\n\u003e \n\u003e l'argument --help ou -h est déjà défini par défaut et affiche l'aide\n\u003e \n\u003e vous pouvez concaténer les arguments courts \n\u003e \n\u003e -a -b -c est équivalent à -abc\n\u003e -a -b -c -f monfichier est equivalent à -abcf monfichier\n\u003e \n\u003e vous pouvez passer comme argument des tableaux et des json\n\u003e ```\n\u003e argjson.add({\n\u003e         arg: \"tab\",\n\u003e         short:\"t\",\n\u003e         description:\"array\",\n\u003e         default:[]\n\u003e });\n\u003e argjson.add({\n\u003e         arg: \"json\",\n\u003e         short:\"j\",\n\u003e         description:\"json\",\n\u003e         default:{}\n\u003e });\n\u003e ```\n\u003e ou\n\u003e ```\n\u003e argjson.add(...).add(...).add(...).add(...)\n\u003e```\n\u003e une fois les arguments définis il suffit de lancer le parser\n\u003e ```\n\u003e var argv=argjson.parse();\n\u003e ```\n\u003e vous retrouvez alors dans argv tous les arguments avec leur nom long\n\u003e ```\n\u003e argv.file\n\u003e argv.verbose\n\u003e argv.tab\n\u003e argv.json\n\u003e ```\n\u003e la syntaxe argv[\"file\"] fonctionne aussi\n\u003e \n\u003e exemple d'utilisation\n\u003e ```\n\u003e node monfichier.js --file test.txt --tab \"[1, 3, 5, 42]\" --size 1024 --factor 1.27 -vxc\n\u003e ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmames%2Fargjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmames%2Fargjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmames%2Fargjson/lists"}