{"id":15652970,"url":"https://github.com/skellock/crappycli","last_synced_at":"2025-03-30T01:26:16.567Z","repository":{"id":150230722,"uuid":"138444512","full_name":"skellock/crappycli","owner":"skellock","description":"A crappy nim package for parsing command line arguments. 💩","archived":false,"fork":false,"pushed_at":"2018-10-28T16:40:49.000Z","size":19,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-05T03:20:32.394Z","etag":null,"topics":["cli","command-line","nim"],"latest_commit_sha":null,"homepage":null,"language":"Nim","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/skellock.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}},"created_at":"2018-06-24T01:23:31.000Z","updated_at":"2024-06-04T02:44:17.000Z","dependencies_parsed_at":"2023-05-09T20:00:23.074Z","dependency_job_id":null,"html_url":"https://github.com/skellock/crappycli","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skellock%2Fcrappycli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skellock%2Fcrappycli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skellock%2Fcrappycli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skellock%2Fcrappycli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skellock","download_url":"https://codeload.github.com/skellock/crappycli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246263802,"owners_count":20749349,"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":["cli","command-line","nim"],"created_at":"2024-10-03T12:44:22.168Z","updated_at":"2025-03-30T01:26:16.533Z","avatar_url":"https://github.com/skellock.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crappycli 💩\n\n[![CircleCI](https://circleci.com/gh/skellock/crappycli.svg?style=svg)](https://circleci.com/gh/skellock/crappycli)\n\nA crappy [`nim`](https://nim-lang.org) package for parsing command line arguments.\n\n\n### Warning\n\nI'm new at `nim` and am extracting this from one of my projects to get used to writing packages.\n\nYou probably want to use one of the many other CLI argument parsing packages instead.  😃\n\n\n# Installing\n\n`nimble install https://github.com/skellock/crappycli`\n\nOr, hey, just copy the `crappycli.nim` file and paste it into your project. 💃\n\n\n# Usage\n\n```nim\nimport crappycli\n\n# new crappy cli!\nlet cli = newCrappyCli()\n\n# check for a switch that's just a flag\ncli.has(\"force\")\n\n# read a switch that has a value\ncli[\"output\"]\n\n# read a switch as an int with a fallback\ncli.intValue(\"l\", 100)\n\n# read a switch as a string with a fallback\ncli.stringValue(\"p\", \"party\")\n\n\n# read positional arguments\ncli.first\ncli.second\ncli.third\ncli.last\ncli.nth(1) # reads the 1st positional argument (1-based 🤓)\n\n# count some stuff\ncli.switchCount\ncli.positionalCount\ncli.empty\n```\n\n### Ambiguous Switches\n\nSometimes your switches will be flags; meaning, they don't have a value associated with them.\n\nBy default, switches consume the next word after them... so, if you want to keep those as positional arguments, then you've gotta tell `CrappyCli` about your flags up front.\n\nLook, I told ya it was crappy! 🎰\n\n```nim\n# alternate way to create it by telling it switches\n# which have no values\nlet cli = commandLineParams.newCrappyCli(\n  flags = @[\"verbose\"]\n)\n\n# ^ used for corner cases where you have positionals\n# right after switches, for example:\n#\n#   mycli -v filename.json\n#\n# ^ in this case, we want the `-v` to be a flag and\n# the `filename.json` to be a positional.\n```\n\n### DIY commandLineParams\n\nBy default, `CrappyCli` tries to read from `commandLineParams` from `os`. You can override this:\n\n```nim\nlet cli = commandLineParams.newCrappyCli(\n  params = @[\"omg\", \"custom\", \"-v\"]\n)\n```\n\n\n# License\n\nMIT. 🤷\n\n\n# Contributing\n\n😂\n\nIf you have any tips, I'm all ears!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskellock%2Fcrappycli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskellock%2Fcrappycli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskellock%2Fcrappycli/lists"}