{"id":17093110,"url":"https://github.com/souvikinator/termparse","last_synced_at":"2026-04-13T01:12:53.045Z","repository":{"id":53496791,"uuid":"315951551","full_name":"souvikinator/termparse","owner":"souvikinator","description":"Minimal node js cli maker","archived":false,"fork":false,"pushed_at":"2021-04-29T06:13:23.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T18:02:00.692Z","etag":null,"topics":["cli","cli-application","command-line","hacktoberfest","hacktoberfest-accepted","hacktoberfest2021","javascript","nodejs","nodejs-modules","term-parse"],"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/souvikinator.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":"2020-11-25T13:43:24.000Z","updated_at":"2022-08-25T03:56:33.000Z","dependencies_parsed_at":"2022-09-10T20:20:50.451Z","dependency_job_id":null,"html_url":"https://github.com/souvikinator/termparse","commit_stats":null,"previous_names":["darthcucumber/termparse"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/souvikinator/termparse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souvikinator%2Ftermparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souvikinator%2Ftermparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souvikinator%2Ftermparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souvikinator%2Ftermparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/souvikinator","download_url":"https://codeload.github.com/souvikinator/termparse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souvikinator%2Ftermparse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29638704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"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":["cli","cli-application","command-line","hacktoberfest","hacktoberfest-accepted","hacktoberfest2021","javascript","nodejs","nodejs-modules","term-parse"],"created_at":"2024-10-14T14:04:43.863Z","updated_at":"2026-02-20T01:55:43.507Z","avatar_url":"https://github.com/souvikinator.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 𝗧𝗲𝗿𝗺𝗽𝗮𝗿𝘀𝗲 \\_\n\nA minimal node js CLI maker.\n\n**Note:** Version 2 has breaking changes so make sure to read below and make changes to your application accordingly\n\n## v2.0.3\n\n- modified the look of usage menu, made it cleaner\n- now args are accessible within the `run` property of `addCommand` using `this.args`. Check below for example.\n\n## v2.0.2 (breaking changes)\n\n- Removed previous methods and added chaining of methods. `setFlags` can be chained with `addCommand`\n- `setFlags` takes in multiple flag property. check below for example\n\n## Technology used:\n\nNo **external dependencies** used apart from **chalk.js** for coloured outputs.\n\n## Features:\n\n- Parses command line arguments like\n  - -flag=value\n  - -flag value\n- Allows user to set commands\n- Can have same named flags for different commands\n- Generates usage details of the CLI application\n\n### Getting started\n\n- use NPM\n  `bash npm i termparse `\n  and you are ready to go\n\n### Demo\n\n```js\nconst Termparse = require(\"termparse\");\n\n//create a instance\nconst tp=new Termparse();\n\n//1st command\ntp.addCommand({\n    name:\"cmd1\",\n    usage:\"this is command 1\",\n    run:function(){\n    \t//adding functionality to cmd1\n\t//this.getFlag(flagName) returns flag object\n        console.log(`accessing flags using getFlag`,this.getFlag(\"flag1\"));\n        //way to access arguments\n        console.log(this.args)\n    }\n}).setFlags({ //chaining setFlags with addCommand\n    name:\"flag1\",\n    usage:\"this is flag 1 for command 1\",\n    type:\"string\",\n    value:\"hahaha\"\n},{\n    name:\"flag2\",\n    usage:\"this is flag 2 for command 1\"\n    //no type and value passed implies default: type:\"boolean\" and value:false\n});\n\n// 2nd command\ntp.addCommand({\n    name:\"cmd2\",\n    usage:\"this is command 2\",\n    run:function(){\n        //another way to access flag object this.flags.\u003cflag_name\u003e\n        console.log(`another way to access flag`,this.flags.gas1);\n\t//another way to access args (non flag type)\n\tconsole.log(tp.args);\n    }\n}).setFlags({\n    name:\"gas1\",\n    usage:\"this is flag 1 (gas 1) for command 2\"\n    type:\"number\",\n    value:2000\n});\n\n// accessing help/usage menu\ntp.showHelp()\n\n//get args from comamnd line\nvar args=process.argv.slice(2);\n//pass arguments to termparse\ntp.parse(args);\n\n```\n\n### Usage:\n\n## `addCommand(options)`\n\nAdds commands to the CLI application.\nTakes command property object as input like so\n\n```json\n{\n  \"name\": \"name of command here\",\n  \"usage\": \"usage details of the command\",\n  \"run\": \"adds functionality to commad\"\n}\n```\n\n- `usage` takes the details of what the command does which is recommended to generate a auto-usage guide.\n- `run` takes function and the function is called when the command is used in terminal.\n\n**NOTE:** do not pass fat arrow function or ()=\u003e{} to run. Rather use function(){}.\n\n## `setFlags(options...)`\n\nAdds flags/options to a specific command of your CLI application. This function is used by chaining it to the `addCommand({...})` function.\n\nTakes in multiple flag property objects as shown in the very first example.\n\n```json\n{\n  \"name\": \"name of flag\",\n  \"type\": \"type of flag\",\n  \"value\": \"value of flag\",\n  \"usage\": \"usage details\"\n}\n```\n\n- `type` can be either `boolean`/`string`/`number`. If no type is passed then default is `boolean`.\n\n- `value` if flag type is boolean then it takes true/false, default being false in boolean. If flag type is string then it takes string as value, default being empty string.\n\n## `getFlag(flag_name)`\n\nGets flag/option object of a specific command of your CLI application. Can be used within the `run` property of the `addCommand({...})`\n\n- `flag` takes name of the flag\n\nreturns flag property object\n\n```json\n//content of flag property object\n{\n  \"type\": \"type of flag\",\n  \"value\": \"value of flag\",\n  \"usage\": \"usage of the flag\",\n  \"present\": \"whether flag is passed as arg or not\"\n}\n```\n\nusing `getFlag()` lets user use the flags value to do various functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouvikinator%2Ftermparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsouvikinator%2Ftermparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouvikinator%2Ftermparse/lists"}