{"id":13475072,"url":"https://github.com/mdbetancourt/soly","last_synced_at":"2025-04-10T20:55:12.228Z","repository":{"id":39867690,"uuid":"431380909","full_name":"mdbetancourt/soly","owner":"mdbetancourt","description":"Powerful framework for building command-line apps with typescript.","archived":false,"fork":false,"pushed_at":"2022-11-01T18:32:56.000Z","size":122,"stargazers_count":90,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T18:45:08.617Z","etag":null,"topics":["cac","cli","command","command-line","commander","framework","node","yargs","zod"],"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/mdbetancourt.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-11-24T07:04:50.000Z","updated_at":"2025-03-22T15:37:47.000Z","dependencies_parsed_at":"2023-01-21T06:46:19.831Z","dependency_job_id":null,"html_url":"https://github.com/mdbetancourt/soly","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdbetancourt%2Fsoly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdbetancourt%2Fsoly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdbetancourt%2Fsoly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdbetancourt%2Fsoly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdbetancourt","download_url":"https://codeload.github.com/mdbetancourt/soly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298101,"owners_count":21080313,"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":["cac","cli","command","command-line","commander","framework","node","yargs","zod"],"created_at":"2024-07-31T16:01:17.153Z","updated_at":"2025-04-10T20:55:12.200Z","avatar_url":"https://github.com/mdbetancourt.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","cli","CLIs"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.svg\" width=\"200px\" align=\"center\" /\u003e\n  \u003ch1 align=\"center\"\u003eSoly\u003c/h1\u003e\n\u003c/p\u003e\n\n**Sol** **Y**ellow, it's a CLI not just for Kryptonians. built with [zod](https://github.com/colinhacks/zod)\n\n## Features\n\n- **Easy to build**. Get default type validation and coercion with some builtin types like `path`, `absolute` or `file`\n- **So powerful**. You get all the power of sun, soly enable you with features like default command, git-like subcommands, docker-like multi commands, parse and coerce arguments and options, variadic arguments, cluster options (-a -b -c -abc) and so on.\n- **Developer friendly**. Written in TypeScript.\n\n## Install\n\n```bash\nyarn add soly\n```\n\nor\n\n```bash\npnpm i soly\n```\n\n### Command-specific Options\n\nYou can attach options to a command.\n\n```ts\nimport { createCLI, path } from 'soly';\nconst cli = createCLI('cli');\n\ncli.command('rm', (rm) =\u003e {\n  // path is used to parse and throw error if the path does not exists\n  const [dir] = rm.positionals([path()]);\n  const { recursive } = rm.flags();\n  recursive.alias('r');\n\n  return () =\u003e {\n    console.log(`remove ${dir.value}${recursive.value ? 'recursively' : ''}`);\n  };\n});\n\ncli.parse();\n```\n\n### Variadic arguments\n\n```ts\nimport { createCLI, string } from 'soly';\nconst cli = createCLI('cli');\n\ncli.command('rm', (rm) =\u003e {\n  // string for every positional\n  const files = rm.positionals(string(), /* min */ 0, /* max */ 10);\n  const { recursive } = rm.flags();\n  recursive.alias('r');\n\n  return () =\u003e {\n    console.log(`Total files ${files.length}`);\n  };\n});\n\ncli.parse();\n```\n\n### Dash in option names\n\nOptions in camelCase it's tranformed to kebab-case:\n\n```ts\nimport { createCLI, number, z } from 'soly';\n\ncli.command('fetch', (fetch) =\u003e {\n  // You can define a type for every value\n  const { maxRetries, method } = fetch.named({\n    maxRetries: number().min(0).default(3),\n    method: z.enum(['http', 'https']).default('http')\n  });\n\n  return () =\u003e {\n    console.log(maxRetries.value); // 4\n  };\n});\n\ncli.parse(['fetch', '--max-retries', '4']);\n```\n\nIn fact `--clear-screen` and `--clearScreen` are both mapped to `options.clearScreen`.\n\n### Optional args\n\nLike [zod](https://github.com/colinhacks/zod) all values are required by default you can make it optional with `.optional` or with `.default`\n\n### Default Command\n\nRegister a command that will be used when no other command is matched.\n\n```ts\nimport { createCLI, number, z } from 'soly';\n\ncli.action(() =\u003e {\n  return () =\u003e {\n    console.log('default command'); // 4\n  };\n});\n\ncli.parse();\n```\n\n### Exclusive flags\n\n```ts\nconst cli = createCLI('cli');\ncli.command('copy', (copy) =\u003e {\n  const { serve } = copy.flags();\n  const { outFolder } = copy.named({\n    outFolder: string().refine(\n      () =\u003e !serve.value,\n      'Output folder cannot be set with serve'\n    )\n  });\n\n  return () =\u003e {\n    outFolder.value;\n  };\n});\ncli.parse();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdbetancourt%2Fsoly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdbetancourt%2Fsoly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdbetancourt%2Fsoly/lists"}