{"id":13818411,"url":"https://github.com/nikstar/CLInterface","last_synced_at":"2025-05-15T23:31:58.153Z","repository":{"id":45236666,"uuid":"194858476","full_name":"nikstar/CLInterface","owner":"nikstar","description":"Elegant @propertyWrapper-based command line argument parser","archived":true,"fork":false,"pushed_at":"2022-01-01T09:19:20.000Z","size":38,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T08:51:21.037Z","etag":null,"topics":["argument-parser","cli","command-line","command-line-parser","property-wrapper","swift","swift-script"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":false,"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/nikstar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-02T12:25:34.000Z","updated_at":"2023-01-28T04:25:27.000Z","dependencies_parsed_at":"2022-08-27T06:10:45.775Z","dependency_job_id":null,"html_url":"https://github.com/nikstar/CLInterface","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/nikstar%2FCLInterface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikstar%2FCLInterface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikstar%2FCLInterface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikstar%2FCLInterface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikstar","download_url":"https://codeload.github.com/nikstar/CLInterface/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442321,"owners_count":22071863,"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":["argument-parser","cli","command-line","command-line-parser","property-wrapper","swift","swift-script"],"created_at":"2024-08-04T07:00:45.336Z","updated_at":"2025-05-15T23:31:57.873Z","avatar_url":"https://github.com/nikstar.png","language":"Swift","readme":"# CLInterface\n\n\u003e __This project is archived.__ I'm happy with how __CLInterface__ turned out; it's architecture includes extensive use of reflection to achieve exactly the API I wanted. Unfortunatly, soon after it's release, Apple came out with its own first-party [argument parser library](https://github.com/apple/swift-argument-parser) that has a very similar interface.\n\nSwift 5.1 era argument parser\n\n[![Swift 5.1](https://img.shields.io/badge/swift-5.1-important)](#)\n[![platforms: macOS, Linux](https://img.shields.io/badge/platforms-macOS%20%7C%20Linux-lightgrey)](#)\n[![Swift Package Manager compatible](https://img.shields.io/badge/spm-compatible-brightgreen)](#)\n[![releases](https://img.shields.io/github/release/nikstar/CLInterface)](https://github.com/nikstar/CLInterface/releases)\n[![MIT license](https://img.shields.io/github/license/nikstar/CLInterface)](LICENSE.md)\n\n`CLInterface` protocol should be implemented by a class or a struct that will represent command line interface of your program. Apart from required `description` property, it should contain `@Argument` and `@PositionalArgument` properties for any arguments you want. They will be set automatically after you call `parseArguments`.\n\nBoth optional and required arguments are supported. Use `default:` and optional properies to get the behavior you want. (For example, non-optional property without default value will throw error at `parseArguments` call.)\n\nUse Swift package manager to add to your project: \n```swift\n        .package(url: \"https://github.com/nikstar/CLInterface.git\", from: \"1.0.3\"),\n```\n\n## Example\n\n```swift\nfinal class Swiftc : CLInterface {\n    var description = \"Swift compiler\"\n\n    @Argument(\"--output\", \"-o\", usage: \"Write output to \u003cfile\u003e\")\n    var outputPath: String?\n    \n    @Argument(\"-g\", usage: \"Emit debug info\", default: false)\n    var debugMode: Bool\n    \n    @PositionalArgument(name: \"files\", usage: \"Files that will be compiled\")\n    var files: [String]\n}\n```\n\nAfter calling `parseArguments`, you will be able to use these properties like normal variables.\n\n```swift\nlet swiftc = Swiftc()\ntry swiftc.parseArguments([\"-o\", \"hello\", \"-g\", \"main.swift\", \"Greeter.swift\"])\n\nswiftc.outputPath // Optional(\"hello\")\nswiftc.debugMode // true\nswiftc.files // [\"main.swift\", \"Greeter.swift\"]\n```\n\n`swiftc -h` or `swiftc --help` prints usage info:\n\n```\nOVERVIEW: Swift compiler\n\nOPTIONS:\n--output, -o   Write output to \u003cfile\u003e\n-g             Emit debug info\n--help         Display available options\n\nPOSITIONAL ARGUMENTS:\nfiles          Files that will be compiled\n```\n\nSee [`ExampleSwiftc`](Sources/ExampleSwiftc/main.swift) for working example.\n\nSee **Opusab**, my audiobook converter, for another [real-life example](https://github.com/nikstar/opusab/blob/master/Sources/OpusabCore/Opusab.swift).\n","funding_links":[],"categories":["Awesome Repositories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikstar%2FCLInterface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikstar%2FCLInterface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikstar%2FCLInterface/lists"}