{"id":19540887,"url":"https://github.com/dimpiax/commandlinerouter","last_synced_at":"2025-02-26T05:17:41.134Z","repository":{"id":147831209,"uuid":"72962202","full_name":"dimpiax/CommandLineRouter","owner":"dimpiax","description":"Library for easy and flexible manipulation with `CommandLine.arguments` in executable product of Swift Package Manager","archived":false,"fork":false,"pushed_at":"2016-11-10T01:48:24.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T18:41:35.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/dimpiax.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":"2016-11-06T00:53:00.000Z","updated_at":"2016-11-15T19:38:37.000Z","dependencies_parsed_at":"2023-05-27T15:45:07.836Z","dependency_job_id":null,"html_url":"https://github.com/dimpiax/CommandLineRouter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FCommandLineRouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FCommandLineRouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FCommandLineRouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FCommandLineRouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimpiax","download_url":"https://codeload.github.com/dimpiax/CommandLineRouter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240795006,"owners_count":19858725,"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":[],"created_at":"2024-11-11T03:07:47.792Z","updated_at":"2025-02-26T05:17:41.109Z","avatar_url":"https://github.com/dimpiax.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CommandLineRouter\n\n[![Language](https://img.shields.io/badge/swift-3.0-fec42e.svg)](https://swift.org/blog/swift-3-0-released/)\n[![License](https://img.shields.io/badge/license-MIT-333333.svg)](https://github.com/dimpiax/CommandLineRouter/blob/master/LICENSE)\n[![Platform](https://img.shields.io/badge/platform-ios osx linux-999999.svg)](https://github.com/dimpiax/CommandLineRouter)\n\n## Description\nLibrary for easy and flexible manipulation with `CommandLine.arguments` in executable product of Swift Package Manager\n\n## Usage\nRun your executable product via SPM, and pass arguments\n`$ .build/debug/Project -i input_file -o output_file`\n\n## Result\nOutput:\n```\nread file input_file\nwrite file output_file\n```\n\n# Example\n```\nimport CommandLineRouter\n\nvar router = CommandLineRouter()\n\n// setup routes\nrouter.setCommands(name: \"Save file\", commands:\n    Command(shortName: \"-i\", name: \"--input\"),\n    Command(shortName: \"-o\", name: \"--output\")\n)\n\nrouter.setCommands(name: \"Export in folder\", commands:\n    Command(shortName: \"-i\", name: \"--input\"),\n    Command(shortName: \"-of\", name: \"--output-folder\")\n)\n\n// process routing\ndo {\n    try router.route(CommandLine.arguments) { flow in\n        switch flow.name {\n            case \"Save file\":\n                let input = flow[0].argument\n                let output = flow[1].argument\n\n                print(\"read file \\(argument)\")\n                print(\"write file \\(argument)\")\n\n            default: break\n        }\n    }\n} catch {\n    print(error)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimpiax%2Fcommandlinerouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimpiax%2Fcommandlinerouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimpiax%2Fcommandlinerouter/lists"}