{"id":13707097,"url":"https://github.com/devOpifex/cmd","last_synced_at":"2025-05-05T23:32:07.018Z","repository":{"id":134705054,"uuid":"436289441","full_name":"devOpifex/cmd","owner":"devOpifex","description":"Code generator to produce CLI from R packages","archived":false,"fork":false,"pushed_at":"2021-12-11T14:11:07.000Z","size":44,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T08:30:47.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devOpifex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-08T15:05:17.000Z","updated_at":"2024-01-07T19:16:00.000Z","dependencies_parsed_at":"2024-01-14T20:34:20.412Z","dependency_job_id":null,"html_url":"https://github.com/devOpifex/cmd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devOpifex%2Fcmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devOpifex%2Fcmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devOpifex%2Fcmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devOpifex%2Fcmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devOpifex","download_url":"https://codeload.github.com/devOpifex/cmd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252593324,"owners_count":21773443,"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-08-02T22:01:19.103Z","updated_at":"2025-05-05T23:32:04.664Z","avatar_url":"https://github.com/devOpifex.png","language":"Go","readme":"![](https://img.shields.io/badge/state-experimental-orange)\n\n# cmd\n\nCreate command line applications from R packages.\n\n\u003cdetails\u003e\n\u003csummary\u003eHow it works\u003c/summary\u003e\nIt's a code generator that outputs Go code which produces\na Command Line Application.\n\nIt's a bit ugly and unwieldy but it does the job.\n\u003c/details\u003e\n\n\n__Using the generated CLI requires an installation of R__\n\n## Install\n\n```bash\ngo get -u devOpifex/cmd\n```\n\n```bash\ngo install -u devOpifex/cmd@latest\n```\n\n## Config\n\nCreate a config file called `cmd.json` at the root of\nyour R package.\n\n```json\n{\n  \"program\": \"rshiny\",\n  \"package\": \"shiny\",\n  \"description\": \"shiny from the command line\",\n  \"install\": \"install.packages('shiny')\",\n  \"commands\": [\n    {\n      \"name\": \"run\",\n      \"short\": \"r\",\n      \"description\": \"run the application\",\n      \"function\": \"runApp\",\n      \"arguments\": [\n        {\n          \"name\": \"dir\",\n          \"short\": \"d\",\n          \"description\": \"directory where the app.R is location\",\n          \"type\": \"string\",\n          \"required\": false,\n          \"default\": \".\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n__Root__\n\nSpecify the name of the `program` this is what users will call\nas root command in their shell. Indicate the `package` this\nCLI wraps.\n\nIn the example above we create a CLI for the shiny package and\ncall the program `rshiny`, e.g.: `rshiny -h` will bring up\nthe help.\n\n__Commands__\n\nList the commands you want to expose to the users of the CLIU,\nthese map to functions from the `package`.\nThe `short` is the short version of the command so one can use\n`rshiny run` or `rshiny r`: this will run `shiny::runApp()`.\n\n__Arguments__\n\nList the arguments the function should take: _these are currently\npassed unnamed so order matters_\n\nType can be one of `string`, `numeric`, `integer` or, `logical`.\n\nAbove makes it such that we can call `rshiny run -d=\"this/dir\"` or\n`rshiny run --dir=/some/path`\n\n__Install__\n\nIs used to generate the `rshiny install` command which installs\nthe required R dependencies.\n\n## Generate\n\nOnce the config file created and cmd installed run `cmd generate`\nfrom the root of the package where the config file is located.\n\nThis creates a directory named after your program.\n\nMove into the created directory \n(e.g.: `cd rshiny` in the example above) \nthen run the folowing.\n\n```bash\ngo mod init github.com/\u003cusername\u003e/\u003crepo\u003e/\u003cprogram\u003e\ngo mod tidy\n```\n\nThe first line will (in part) ensure you can work with go outside\nof your `GOROOT`, the second downloads dependencies if there are\nany (currently only [cobra](https://github.com/spf13/cobra)).\n\nYou should only need to run the above once. No need to repeat the \nprocess if you want to update your config and regenerate the code\nwith `cmd generate`.\n\nThen to build run the following.\n\n```bash\ngo build\n```\n\nThis should produce a program you can call from the command line.\nIf you only need it on your own system you can just call\n`go install`.\n\nBy default `go build` builds for your system, you can easily\nbuild for other system with:\n\n```r\nGOOS=linux go build\nGOOS=windows go build\nGOOS=darwin go build\n```\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FdevOpifex%2Fcmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FdevOpifex%2Fcmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FdevOpifex%2Fcmd/lists"}