{"id":16292063,"url":"https://github.com/drewolson/clip","last_synced_at":"2026-02-22T04:35:39.948Z","repository":{"id":256404886,"uuid":"855181768","full_name":"drewolson/clip","owner":"drewolson","description":"A CLI option parser for Gleam","archived":false,"fork":false,"pushed_at":"2026-02-20T14:24:10.000Z","size":117,"stargazers_count":47,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-20T18:50:05.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Gleam","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drewolson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-10T13:02:07.000Z","updated_at":"2026-02-20T14:24:14.000Z","dependencies_parsed_at":"2025-05-30T12:07:42.073Z","dependency_job_id":"cd46b1c8-5438-4ca8-a318-8754668c4d2e","html_url":"https://github.com/drewolson/clip","commit_stats":null,"previous_names":["drewolson/clip"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/drewolson/clip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fclip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fclip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fclip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fclip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drewolson","download_url":"https://codeload.github.com/drewolson/clip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fclip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T03:17:42.375Z","status":"ssl_error","status_checked_at":"2026-02-22T03:17:31.622Z","response_time":110,"last_error":"SSL_read: 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":[],"created_at":"2024-10-10T20:01:27.458Z","updated_at":"2026-02-22T04:35:39.940Z","avatar_url":"https://github.com/drewolson.png","language":"Gleam","funding_links":[],"categories":["Packages"],"sub_categories":["Command Line"],"readme":"# clip - A CLI option parser for Gleam\n\n[![Package Version](https://img.shields.io/hexpm/v/clip)](https://hex.pm/packages/clip)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/clip/)\n\n`clip` is a library for parsing command line interface options.\n\n## Simple Example\n\n```gleam\nimport argv\nimport clip.{type Command}\nimport clip/help\nimport clip/opt.{type Opt}\nimport gleam/io\nimport gleam/string\n\ntype Person {\n  Person(name: String, age: Int)\n}\n\nfn name_opt() -\u003e Opt(String) {\n  opt.new(\"name\") |\u003e opt.help(\"Your name\")\n}\n\nfn age_opt() -\u003e Opt(Int) {\n  opt.new(\"age\") |\u003e opt.int |\u003e opt.help(\"Your age\")\n}\n\nfn command() -\u003e Command(Person) {\n  clip.command({\n    use name \u003c- clip.parameter\n    use age \u003c- clip.parameter\n\n    Person(name, age)\n  })\n  |\u003e clip.opt(name_opt())\n  |\u003e clip.opt(age_opt())\n}\n\npub fn main() -\u003e Nil {\n  let result =\n    command()\n    |\u003e clip.help(help.simple(\"person\", \"Create a person\"))\n    |\u003e clip.run(argv.load().arguments)\n\n  case result {\n    Error(e) -\u003e io.println_error(e)\n    Ok(person) -\u003e person |\u003e string.inspect |\u003e io.println\n  }\n}\n```\n\n```\n$ gleam run -- --help\n   Compiled in 0.00s\n    Running cli.main\nperson\n\n  Create a person\n\nUsage:\n\n  person [OPTIONS]\n\nOptions:\n\n  (--name NAME) Your name\n  (--age AGE)   Your age\n  [--help,-h]   Print this help\n```\n\n```\n$ gleam run -- --name Drew --age 42\n   Compiled in 0.00s\n    Running cli.main\nPerson(\"Drew\", 42)\n```\n\n## Using `clip`\n\n`clip` is an \"applicative style\" options parser. To use `clip`, follow these\nsteps:\n\n1. First, invoke `clip.command` providing a function to be called with your\n   parsed options. This function can be built using the\n   [parameter syntax](https://hexdocs.pm/clip/clip.html#parameter).\n   Alternatively, you can directly provide a curried function, meaning a two argument\n   function looks like `fn(a) { fn(b) { do_stuff(a, b) } }`. You can also use\n   the pre-built commands `clip.command1`, `clip.command2`, etc.\n2. Next, use the `|\u003e` operator along with `clip.opt`, `clip.flag`, and\n   `clip.arg` to parse command line arguments and provide them as parameters to\n   the function given to `clip.command`.\n3. Optionally use `clip.help` and `clip/help` to generate help text for your\n   command. The user can view this help text via the `--help,-h` flag.\n4. Finally, run your parser with `clip.run`, giving it the command you have\n   built and the list arguments to parse. I recommend using the `argv` library\n   to access these arguments from both erlang and javascript.\n\n## Types of Options\n\n`clip` provides three types of options:\n\n1. An `Option` is a named option with a value, like `--name \"Drew\"`. You create\n   `Option`s with the `clip/opt` module and add them to your command with the\n   `clip.opt` function.\n2. A `Flag` is a named option without a value, like `--verbose`. If provided, it\n   produces `True`, if not provided it produces `False`. You create `Flag`s with\n   the `clip/flag` module and add them to your command with the `clip.flag`\n   function.\n3. An `Argument` is a positional value passed to your command. You create\n   `Argument`s with the `clip/arg` module and add them to your command with the\n   `clip.arg`, `clip.arg_many`, and `clip.arg_many1` functions.\n\nTake a look at the\n[examples](https://github.com/drewolson/clip/tree/main/examples) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewolson%2Fclip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrewolson%2Fclip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewolson%2Fclip/lists"}