{"id":19920954,"url":"https://github.com/nrjais/cmd-line-args-parser","last_synced_at":"2026-06-10T19:31:05.270Z","repository":{"id":57201117,"uuid":"110006961","full_name":"nrjais/cmd-line-args-parser","owner":"nrjais","description":"An parser to parse arguments given in terminal to make an terminal or command line app.","archived":false,"fork":false,"pushed_at":"2017-11-15T05:27:06.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-24T03:07:51.978Z","etag":null,"topics":["argument-parsing","command-line","command-line-arguments-parser","command-line-parser","parser-framework"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nrjais.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":"2017-11-08T17:19:11.000Z","updated_at":"2017-11-10T09:09:48.000Z","dependencies_parsed_at":"2022-09-15T11:23:07.061Z","dependency_job_id":null,"html_url":"https://github.com/nrjais/cmd-line-args-parser","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/nrjais/cmd-line-args-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjais%2Fcmd-line-args-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjais%2Fcmd-line-args-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjais%2Fcmd-line-args-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjais%2Fcmd-line-args-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nrjais","download_url":"https://codeload.github.com/nrjais/cmd-line-args-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjais%2Fcmd-line-args-parser/sbom","scorecard":{"id":696768,"data":{"date":"2025-08-11","repo":{"name":"github.com/nrjais/cmd-line-args-parser","commit":"a066565e99a8f095262864b24bb0ed8ae5e07829"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"Code-Review","score":0,"reason":"Found 1/21 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":"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: 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 'master'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T03:56:27.218Z","repository_id":57201117,"created_at":"2025-08-22T03:56:27.219Z","updated_at":"2025-08-22T03:56:27.219Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34168086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-parsing","command-line","command-line-arguments-parser","command-line-parser","parser-framework"],"created_at":"2024-11-12T22:06:22.753Z","updated_at":"2026-06-10T19:31:05.253Z","avatar_url":"https://github.com/nrjais.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Join the chat at https://gitter.im/cmd-line-args-parser/Lobby](https://badges.gitter.im/cmd-line-args-parser/Lobby.svg)](https://gitter.im/cmd-line-args-parser/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) [![CircleCI](https://circleci.com/gh/nrjais/cmd-line-args-parser/tree/master.svg?style=shield\u0026circle-token=897e6a1defad17b1f69f974d5457ac530f4c0f7f)](https://circleci.com/gh/nrjais/cmd-line-args-parser/tree/master) [![Build Status](https://travis-ci.org/nrjais/cmd-line-args-parser.svg?branch=master)](https://travis-ci.org/nrjais/cmd-line-args-parser) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n# cmd-line-args-parser\n\nThis is a command line arguments parser written in Javascript that helps parse command line arguments and it will return object with boolean-flags array ,value-option object and arguments list. You have to define rules to parse in a defined structure.\n\n## Motivation\n\nI am implementing head (shell command) functionality using node js I found that it's difficult write individual parser for each command So by installing this module you can build any command easily even if you are building your own command.\n\n## Installation\n\n`npm install cmd-line-args-parser`\n\n## Usage\n\n```javascript\nvar Parser=require('cmd-line-args-parser');\n\nvar parserName=new Parser(rules);\n\n//the following is the structure for specifying rules\n\nrules = {\n  validOptions: [],    //all the valid options that require values\n  default: {            //default option to set if no option specified\n    'n': 10\n  },\n  minimum: 1,           /*\n                          minimum number of required options if the arguments have\n                          less than minimum options than default option will be set*/\n  maximum: 1,           /*\n                          maximum number of required options that are allowed\n                          otherwise an error will be thrown*/\n  flags: [],             //all the flags allowed\n  replacer: {}           /*\n                          rules that define replacers so that they can be converted\n                          to a flag\n                        */\n}\n\n //pass an array of  things to parse method to get parsedArguments\n parserName.parse(args); //example let args =['-n','10','files'] for head\n```\n\n### Examples\n\n#### Head command Parser\n\n```javascript\n  var Parser=require('cmd-line-args-parser');\n\n  rules = {               //rules for head command\n    validOptions: ['n','c'],\n    default: {\n      'n': 10\n    },\n    minimum: 1,\n    maximum: 1,\n    flags: ['h'],\n    replacer: {'help':'h'} //here --help will be replaced by 'h' so 'h' should be valid flag\n  }\n\n\n\n  parserName.setCombinedFlags(true);\n  /*\n    false by default\n    if false then two or more flags cannot be combined\n    like '-acs'  will not work\n    if true then it will be ['a','c','s']\n  */\n\n  //default if not given\n  let containsValue = function(value) {\n    let regex = /(\\d)+$/g\n    return regex.test(value);\n  }\n\n  /*\n    containsValue is a function that can verify if a value is in the option or not\n    like -n10 here 10 is the value so the function can determine if the\n    option contains the value\n    or not.\n  */\n  parserName.setContainsValue(containsValue);\n\n\n  let isNumber = function(value){\n    return Number.isInteger(+value);\n  };\n  /*\n    isNumber is the function that determines if the value given value is legal or not\n    if this function is not given then the below function is used by default.\n  */\n  parserName.setIsValue(isNumber);\n  /*\n    if no isValue function is set then the above isNumber will be used\n    by default\n  */\n\n  let headParser = new Parser(rules);\n\n  /*\n    once some arguments are parsed then you need to reset the parser\n    to parse new arguments again\n    you can do that by\n  */\n  parserName.reset();\n\n  //then you can reuse your parser\n  parserName.parse(args);\n\n```\n\n## Errors thrown at different cases\n\n```javascript\n{\n  name:'MaxOptions',\n  message:'Cannot combine : -option1 -option2'\n}\n{\n  name:'MissingValue',\n  message:'Value of : -option is missing'}\n{\n  name:'IllegalOption',\n  message:'Illegal option : -option'\n}\n{\n  name:'CombiningFlags',                    //only when combinedFlags is set false\n  message:'Combining Multiple flags not allowed'\n}\n```\n\n## Different cases output for above parser rules\n\n```javascript\n  args=['-n10','-c12'];\n  //output\n  Error:Cannot combine options : -n -c\n\n  args=['-n10',\"toDo.txt\"];\n  //output\n  {\n    flags: [],\n    options: {\n      n: 10\n    },\n    setByDefault : false,                   //this will be true when the option is set using default\n    arguments: [\"toDo.txt\"]\n  }\n\n  args=[\"--help\"];\n  //output\n  {\n    flags: ['h'],\n    options: {\n      n: 10\n    },\n    setByDefault : true,\n    arguments: []\n  }\n\n  args=['-n12',\"toDo.txt\"];//once it see argument remaining everything is argument\n  //output\n  {\n    flags: [],\n    options: {\n      n: 12\n    },\n    setByDefault : false,\n    arguments: [\"toDo.txt\"]\n  }\n\n  args=[];\n  //output\n  {\n    flags: [],\n    options: {\n      n: 10\n    },\n    setByDefault : true,\n    arguments: []\n  }\n\n\n  args =['-10'];\n  //output\n  {\n    flags: [],\n    options: {\n      n: 10\n    },\n    setByDefault : false,\n    arguments: []\n  }\n```\n\n### Unsupported Cases\n\n```javascript\n//when args as below\nargs=['-n10','-20'];\n//it will replace n value with 20 because default option is n\n{\n  flags: [],\n  options: {\n    n: 20\n  },\n  setByDefault : false,\n  arguments: [\"toDo.txt\"]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrjais%2Fcmd-line-args-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnrjais%2Fcmd-line-args-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrjais%2Fcmd-line-args-parser/lists"}