{"id":15486512,"url":"https://github.com/dyedgreen/clay","last_synced_at":"2025-03-04T01:31:50.594Z","repository":{"id":62422478,"uuid":"440328181","full_name":"dyedgreen/clay","owner":"dyedgreen","description":"Deno Command Line Parser","archived":false,"fork":false,"pushed_at":"2021-12-28T15:41:39.000Z","size":61,"stargazers_count":13,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-19T07:15:32.364Z","etag":null,"topics":["cli","deno","javascript","parsing","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/dyedgreen.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":"2021-12-20T22:56:53.000Z","updated_at":"2024-09-21T14:46:13.000Z","dependencies_parsed_at":"2022-11-01T17:31:30.306Z","dependency_job_id":null,"html_url":"https://github.com/dyedgreen/clay","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyedgreen%2Fclay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyedgreen%2Fclay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyedgreen%2Fclay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyedgreen%2Fclay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dyedgreen","download_url":"https://codeload.github.com/dyedgreen/clay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241768283,"owners_count":20017116,"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","deno","javascript","parsing","typescript"],"created_at":"2024-10-02T06:08:42.784Z","updated_at":"2025-03-04T01:31:50.320Z","avatar_url":"https://github.com/dyedgreen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clay - Deno Command Line Argument Parsing\n\n[![tests](https://github.com/dyedgreen/clay/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/dyedgreen/clay/actions/workflows/tests.yml)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https://deno.land/x/clay/mod.ts)\n\nEasily convert command line arguments to objects. Try the example:\n\n```bash\n$ deno run https://deno.land/x/clay/example.ts --help\n```\n\n## Features\n\n- Type-safe, extensible argument parsing\n- Support for named arguments (passed as `--flags`) and positional arguments\n- Automatically generated help messages (accessible with `-h` or `--help`)\n- Automatically generated error messages, including suggestions for misspelled\n  arguments\n\n## Code Examples\n\nA simple command with two options, one of which is required.\n\n```ts\nimport { Command, number, string } from \"https://deno.land/x/clay/mod.ts\";\n\nconst cmd = new Command(\"A simple example.\")\n  .required(string, \"name\", { flags: [\"n\", \"name\"], description: \"The name.\" })\n  .optional(number, \"age\", { flags: [\"a\", \"age\"], description: \"The age.\" });\n\nconsole.log(cmd.run()); // { name: string, age: number | null }\n```\n\nAnonymous (positional) arguments, as well as simple yes / no flag options are\nsupported as well.\n\n```ts\nimport { Command, string } from \"https://deno.land/x/clay/mod.ts\";\n\nconst cmd = new Command(\"Example with anonymous arguments and flags.\")\n  .required(string, \"file\")\n  .flag(\"overwrite\", { aliases: [\"o\"], description: \"Overwrite the file.\" });\n\nconsole.log(cmd.run()); // { file: string, overwrite: boolean }\n```\n\nA command group can contain multiple sub-commands. Notice that empty commands\nare also possible.\n\n```ts\nimport {\n  choice,\n  Command,\n  CommandGroup,\n  integer,\n} from \"https://deno.land/x/clay/mod.ts\";\n\nconst create = new Command(\"Create a new resource.\");\nconst destroy = new Command(\"Destroy a given resource.\")\n  .required(integer, \"id\")\n  .required(choice(\"CONFIRM\", [\"y\", \"yes\", \"ok\"]), \"confirm\", {\n    flags: [\"confirm\"],\n    description: \"Confirm this action.\",\n  });\n\nconst manage = new CommandGroup(\"Manage imaginary resources.\")\n  .subcommand(\"create\", create)\n  .subcommand(\"destroy\", destroy);\n\nconsole.log(manage.run()); // { create?: {}, destroy?: { id: number, confirm: \"y\"|\"yes\"|\"ok\" } }\n```\n\nDefining new parsers for custom types is also possible.\n\n```ts\ntype email = string;\n\nconst email = {\n  parse: (raw: string): email =\u003e {\n    if (/^[a-z0-9-_.]+@[a-z0-9-_.]+$/i.test(raw)) {\n      return raw;\n    } else {\n      throw new Error(\n        `'${raw.replaceAll(\"'\", \"\\\\'\")}' is not a recognized email address`,\n      );\n    }\n  },\n  typeName: \"EMAIL\",\n};\nconst cmd = new Command(\"Example with a custom type.\")\n  .required(email, \"email\");\n\nconsole.log(cmd.run()); // { email: email }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyedgreen%2Fclay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdyedgreen%2Fclay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyedgreen%2Fclay/lists"}