{"id":22202147,"url":"https://github.com/rumkin/argentum","last_synced_at":"2025-03-25T00:59:18.455Z","repository":{"id":57183522,"uuid":"46911511","full_name":"rumkin/argentum","owner":"rumkin","description":"Node.js cli arguments parser","archived":false,"fork":false,"pushed_at":"2016-07-29T11:07:26.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T05:20:21.511Z","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/rumkin.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}},"created_at":"2015-11-26T07:43:24.000Z","updated_at":"2019-08-29T05:47:12.000Z","dependencies_parsed_at":"2022-08-23T01:01:31.996Z","dependency_job_id":null,"html_url":"https://github.com/rumkin/argentum","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/rumkin%2Fargentum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fargentum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fargentum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fargentum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rumkin","download_url":"https://codeload.github.com/rumkin/argentum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245377988,"owners_count":20605377,"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-12-02T16:12:33.894Z","updated_at":"2025-03-25T00:59:18.433Z","avatar_url":"https://github.com/rumkin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Argentum\n---\n\n![Build](https://img.shields.io/travis/rumkin/argentum.svg)\n[![Coverage Status](https://coveralls.io/repos/rumkin/argentum/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/rumkin/argentum?branch=master)\n\n\nArgentum is a unified command line arguments parser. It parses arguments into\nJS values boolean, number, date, string or array of values. Argentum has no\nschema like other parsers it just try to parse all passed values.\n\nIt has several rules to parse values:\n* Rule could be `--name`, `--name=value`, `--name[]` and `--name[]=value`.\n* Kebab case converts into camel case `--some-name` becomes `someName`.\n* Empty property value is true: `--bool` mean `true`.\n* Arrays overwrite previous value: `--arr=1 --arr[]` has empty array with name `arr`.\n\nNote that parsed values pull out from passed array.\n\n## Example\n\nArgentum converts command line arguments into appropriate JS types.\n\n```shell\nnode app.js --host=localhost --port=8080 --dirs[] public build\n```\n\nResult of parsing is:\n\n```javascript\n{\n  host: 'localhost',\n  port: 8080,\n  dirs: ['public', 'build']\n}\n```\n\n## Usage\n\n```javascript\nvar argentum = require('argentum');\n\n// Parsing\nargentum.parse(['--hello=world']); // -\u003e {hello: \"world\"}\n\n// Splicing\nvar args = ['-x', 'value', '-d'];\nargentum.parse(args); // -\u003e {x: true, d: true}\nargs; // -\u003e ['value']\n```\n\nParsing schema\n\n| Cli               | JavaScript         |\n|:------------------|:-------------------|\n| `-v`              | `{v: true}`        |\n| `--hello=world`   | `{hello: 'world'}` |\n| `--number=1`      | `{number: 1}`      |\n| `--bool`          | `{bool: true}`     |\n| `--a[] 1 2`       | `{a: [1,2]}`       |\n| `--a[]=1 --a[]=2` | `{a: [1,2]}`       |\n\n\n## Interface\n\nPackage require interface.\n\n## parse(string[], options{}) -\u003e object\n\nParse array of strings and return an object of properties.\n\n### options.defaults -\u003e object\n\nDefault values dictionary. Example:\n\n```javascript\nvar args = argentum.parse(\n    ['--verbose'],\n    {defaults:{\n        debug: true\n    }}\n);\nargs; // -\u003e {debug: true, verbose: true}\n```\n\n### options.aliases -\u003e object\n\nAliases dictionary where key is alias and value is the property. Example:\n\n```javascript\nvar args = argentum.parse(\n    ['-d'],\n    {aliases:{\n        d: 'debug'\n    }}\n);\nargs; // -\u003e {debug: true}\n```\n\n### options.eval -\u003e bool\n\nIf passed then all string values in source array will be converted in their js\nequivalent:\n\n```javascript\nvar argv = ['1', '10.99', 'true', 'false', 'hello'];\nargentum.parse(argv, {eval: true});\nargv; // =\u003e [1, 10.99, true, false, 'hello']\n```\n\n## parseValue(string) -\u003e boolean|number|string\n\nParse string value to match `true`, `false` or number patterns otherwise return\nstring.\n\n## split(args string[],limit number) -\u003e string[][]\n\nSplit array into two arrays with double hyphen as separator. Limit should match\ncount of found separators.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fargentum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frumkin%2Fargentum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fargentum/lists"}