{"id":34984703,"url":"https://github.com/ava-cassiopeia/really-simple-args","last_synced_at":"2026-04-13T01:16:23.885Z","repository":{"id":44955688,"uuid":"102068769","full_name":"ava-cassiopeia/really-simple-args","owner":"ava-cassiopeia","description":"Node module for easily managing args for Node CLI tools","archived":false,"fork":false,"pushed_at":"2022-12-27T15:52:17.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T00:42:48.014Z","etag":null,"topics":["args","arguments","cli","node","npm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ava-cassiopeia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-01T03:14:13.000Z","updated_at":"2022-01-15T20:43:34.000Z","dependencies_parsed_at":"2023-01-31T04:45:44.946Z","dependency_job_id":null,"html_url":"https://github.com/ava-cassiopeia/really-simple-args","commit_stats":null,"previous_names":["aeolingamenfel/really-simple-args"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ava-cassiopeia/really-simple-args","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ava-cassiopeia%2Freally-simple-args","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ava-cassiopeia%2Freally-simple-args/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ava-cassiopeia%2Freally-simple-args/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ava-cassiopeia%2Freally-simple-args/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ava-cassiopeia","download_url":"https://codeload.github.com/ava-cassiopeia/really-simple-args/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ava-cassiopeia%2Freally-simple-args/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31735907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T22:19:12.206Z","status":"ssl_error","status_checked_at":"2026-04-12T22:18:33.088Z","response_time":58,"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":["args","arguments","cli","node","npm"],"created_at":"2025-12-27T01:27:04.865Z","updated_at":"2026-04-13T01:16:23.872Z","avatar_url":"https://github.com/ava-cassiopeia.png","language":"JavaScript","readme":"# Really Simple Args\n\n[![npm version](https://badge.fury.io/js/really-simple-args.svg)](https://badge.fury.io/js/really-simple-args)\n[![Build Status](https://travis-ci.org/aeolingamenfel/really-simple-args.svg?branch=master)](https://travis-ci.org/aeolingamenfel/really-simple-args)\n\nNPM/Node CommonJS module for automatically sorting and managing command-line \narguments for your command line tool.\n\n---\n\n  - [Installation](#installation)\n  - [Simple Usage](#simple-usage)\n  - [Concepts](#concepts)\n  - [Usage](#usage)\n    - [Register Shorthands](#register-shorthands)\n    - [Get Argument by Index](#get-argument-by-index)\n    - [Get Amount of Arguments](#get-amount-of-arguments)\n    - [Determine if Flag Exists](#determine-if-flag-exists)\n    - [Determine if Parameter Exists](#determine-if-parameter-exists)\n    - [Get Parameter Value](#get-parameter-value)\n    - [Determine if Shorthand Exists](#determine-if-shorthand-exists)\n    - [Determine if Shorthand is Being Used](#determine-if-shorthand-is-being-used)\n\n## Installation\n\nTo install, simply run:\n\n```CLI\nnpm i --save really-simple-args\n```\n\n## Simple Usage\n\nBelow is a simple example of what you can do with this code. See the \n[usage section](#usage) for more information.\n\n```Javascript\nconst args = require(\"really-simple-args\")();\n\nif(args.hasFlag(\"my-flag\")) {\n    // do something when --my-flag is passed\n}\n\nif(args.hasParameter(\"p\")) {\n    const pValue = args.getParameter(\"p\");\n\n    // do something with pValue, which was passed with -p\n}\n```\n\nor in Typescript:\n\n```Typescript\nimport parseArgs from \"really-simple-args\";\n\nconst args = parseArgs();\n\nif(args.hasFlag(\"my-flag\")) {\n    // do something when --my-flag is passed\n}\n\nif(args.hasParameter(\"p\")) {\n    const pValue = args.getParameter(\"p\");\n\n    // do something with pValue, which was passed with -p\n}\n```\n\n## Concepts\n\nThis repository, and by extension the `really-simple-args` tool, use the terms\nArgument, Parameter, Flag, and Shorthand. See below for how that is defined for\nthis project, to avoid any confusion.\n\n### Parameter\n\nAnything that starts with a single `-` character, and is followed by some value.\n\n*Example:*\n\n```\nmy-cli-tool -u root\n```\n\nIn this case, `u` is a parameter, and its value is the string `root`. \n\n### Flag\n\nAnything that starts with two `-` characters. Does not have any associated \nvalue.\n\n*Example:*\n\n```\nmy-cli-tool --foobar --my-flag\n```\n\nIn this case, both `foobar` and `my-flag` are flags.\n\n### Argument\n\nAnything that isn't a parameter, flag, or shorthand, and isn't the value of a\nparameter.\n\n*Example:*\n\n```\nmy-cli-tool --foobar -a b --baz my-parameter\n```\n\nIn thiscase, neither `foobar`, `baz`, `a`, *or* `b` are considered parameters\nby `really-simple-args`. Only `my-parameter` is a parameter, and would be in \nparameter slot `0`. \n\n### Shorthand\n\nA shorthand is a single character argument. It can either appear solo with a `-`\npreceding it, or shorthands can be batched together, any number of them together\nin one sequence with a `-` before it.\n\nIn addition, shorthands must be registered with this tool in order to be \nrecognized, to avoid shorthands overlapping parameters. Shorthands can also \nrepresent other parameters or flags. See the [Usage](#usage) section for more\ninformation on how to register shorthands.\n\n*Example:*\n\nLet's assume that you have previously registered the shorthands `a` and `c`,\nand your CLI tool was called like this:\n\n```\nmy-cli-tool --foo -ac baz\n```\n\nIn a normal case, `ac` would be an available parameter, with the value of `baz`.\nHowever, in this case, because you have registered those shorthands, the\nshorthands `a` and `c` would both be present, and `baz` would become an argument\nin argument index `0`.\n\nIt's also worth noting that these shorthands have been batched together, but the\nsame exact result would be true if specified like:\n\n```\nmy-cli-tool --foo -a -c baz\n```\n\nOr like this:\n\n```\nmy-cli-tool -a --foo baz -c\n```\n\nFinally, since shorthands *can* (but do not have to) represent flags and \nparameters, it's possible that the shorthand `a` could represent flag `foo`,\nwhich would then cause `really-simple-args` to throw an error, because the `foo`\nflag is present twice. See the [Usage](#usage) section for more information on\nregistering and using shorthands.\n\n## Usage\n\nFirst, add it to your source file that you want to read arguments from:\n\n```Javascript\nconst args = require(\"really-simple-args\")();\n```\n\nThis will automatically cause the args manager to sort and cache all your \narguments, so you can then use methods on the `args` object to access and \ncheck to see if any arguments/parameters/flags were used.\n\nThe args manager *will* throw an error if multiple flags or arguments exist.\n\nUnless otherwise specified below, all of these methods can be called off of the \n`args` object, or whatever you choose to name it.\n\n### Register Shorthands\n\nWhen constructing `really-simple-args`, you can optionally pass an array of\nshorthands as the first parameter:\n\n```Javascript\nconst args = require(\"really-simple-args\")([/* shorthands go here */]);\n\n// Or if you want a more legible syntax\nconst parseArgs = require(\"really-simple-args\");\n\nconst args = parseArgs([\n    /* shorthands go here */\n]);\n```\n\nShorthands are single character special arguments that can optionally represent\nflags or parameters.\n\nTo specify a shorthand that doesn't represent any other arguments, just pass it\nas a string:\n\n```Javascript\nconst args = require(\"really-simple-args\")([\"a\", \"b\"]);\n\n// Assuming the CLI was called like: my-cli -ab\n\nargs.shorthandIsPresent(\"a\"); // true\nargs.shorthandIsPresent(\"b\"); // true\n```\n\nIn the case above, the shorthands `a` and `b` are now registered.\n\nYou can also make shorthands represent certain flags or parameters by passing\na configuration object instead of a string for a shorthand:\n\n```Javascript\nconst args = require(\"really-simple-args\")([\n    \"a\",\n    {\n        name: \"b\",\n        shortFor: [\n            \"--foo\",\n            [\"-bar\", \"param0\"]\n        ]\n    }\n]);\n\n// Assuming the CLI was called like: my-cli -ab\n\nargs.shorthandIsPresent(\"a\"); // true\nargs.shorthandIsPresent(\"b\"); // true\nargs.hasFlag(\"foo\"); // true\nargs.hasParameter(\"bar\"); // true\nargs.getParameter(\"bar\"); // \"param0\"\n```\n\nIn the above, the shorthands `a` and `b` are still present, similar to the last\nexample. However, in this example, the shorthand `b` is short for the `foo`\nflag. This means that whenever the `b` shorthand is present, it will act as both\na shorthand and a flag. If you were to check to see if the `foo` flag was\npresent when the `b` shorthand was specified, it would return true.\n\nIn the same vein, the parameter `bar` is also present with the value of `param0`\nwhenever the shorthand `b` is present.\n\nAs you may have noticed, the `shortFor` property is an array. A shorthand can \nhave any number of flags or parameters that it represents.\n\n**Warning:** Flags and parameters specified for a shorthand function exactly as\nthough the user specified those flags/parameters where the shorthand is. This \nmeans that if the flag that a shorthand represents is present again later in the\narguments, this tool will throw an error.\n\n### Get Argument by Index\n\n```\ngetArgumentByIndex(index: Integer): String|undefined\n```\n\nRetrieves an argument based on its index. Will either return the argument value\nor `undefined` if an argument at the specified index does not exist.\n\nThe index an argument is assigned assumes that the command, any flags, and \nany parameters and their values are not counted. So, for example, given a call \nlike:\n\n```\nmy-cli --foo -bar baz --foobar my-argument --foobaz another-argument\n```\n\nThe computed index of `my-argument` in this example is `0`, and the computed \nindex of `another-argument` is `1`, as all the other parts are ignored.\n\n### Get Amount of Arguments\n\n```\ngetAmountOfArguments(): Integer\n```\n\nReturns the amount of floating arguments (arguments not part of a flag or \nparameter).\n\n### Determine if Flag Exists\n\n```\nhasFlag(name: String): Boolean\n```\n\nReturns true if the specified flag `name` exists. The flag name should be the \nname of the flag minus the `--` at the beginning.\n\n### Determine if Parameter Exists\n\n```\nhasParameter(name: String): Boolean\n```\n\nReturns true if the specified parameter `name` exists. The parameter name should\nbe the name of the parameter minus the `-` at the beginning.\n\n### Get Parameter Value\n\n```\ngetParameter(name: String): String|null\n```\n\nReturns the value of the specified parameter (by name) if it exists, or `null`\nif it does not. The name of the parameter should be the parameter minus the `-`\nat the beginning.\n\n### Determine If Shorthand Exists\n\n```\nhasShorthand(name: String): Boolean\n```\n\nReturns true if the given shorthand (without `-` prefix) has been\n**registered**. This does not indicate whether or not the CLI has been called\nwith the given shorthand.\n\n### Determine If Shorthand Is Being Used\n\n```\nshorthandIsPresent(name: String): Boolean\n```\n\nReturns true if the given shorthand (without the `-` prefix) is present in the \narguments of the CLI tool, either in shorted form (`-ab`) or in spaced form\n(`-a -b`).\n\nKeep in mind that if a shorthand proxies flags or parameters, you can find\nwhether those exist using their appropriate methods.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fava-cassiopeia%2Freally-simple-args","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fava-cassiopeia%2Freally-simple-args","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fava-cassiopeia%2Freally-simple-args/lists"}