{"id":23465819,"url":"https://github.com/kristofferahl/go-centry","last_synced_at":"2025-07-21T07:34:22.397Z","repository":{"id":46809579,"uuid":"235329714","full_name":"kristofferahl/go-centry","owner":"kristofferahl","description":"Declarative command line builder for teams and one man bands","archived":false,"fork":false,"pushed_at":"2024-02-26T17:04:56.000Z","size":261,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T17:44:47.645Z","etag":null,"topics":["bash","cli"],"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/kristofferahl.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,"dei":null}},"created_at":"2020-01-21T11:45:51.000Z","updated_at":"2025-04-24T10:56:56.000Z","dependencies_parsed_at":"2024-02-26T18:28:52.572Z","dependency_job_id":"9a539447-c809-4aeb-b1b0-e8416172f515","html_url":"https://github.com/kristofferahl/go-centry","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/kristofferahl/go-centry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristofferahl%2Fgo-centry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristofferahl%2Fgo-centry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristofferahl%2Fgo-centry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristofferahl%2Fgo-centry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kristofferahl","download_url":"https://codeload.github.com/kristofferahl/go-centry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristofferahl%2Fgo-centry/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266261391,"owners_count":23901290,"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":["bash","cli"],"created_at":"2024-12-24T11:39:51.745Z","updated_at":"2025-07-21T07:34:22.154Z","avatar_url":"https://github.com/kristofferahl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# centry\n\nDeclarative **command line builder** for teams and one man bands\n\n## Use cases\n\n- Build a feature rich CLI from scratch using only scripts and yaml\n- Bundle existing scripts and tools as a single CLI\n- Encode best practices and team conventions for using scripts and dev/ops tools\n\n## Feature highlights\n\n- **Declarative**: Add new commands and options and run them at once. No need to re-compile.\n- **Unified syntax**: Provides a standard for using commands and options.\n- **Supports multi level commands**: `mycli get status` and `mycli get files`\n- **Supports multi level options (flags)**: `mycli --dev get status --out json`\n- **Contextual help**: `mycli get --help`\n- **Autocomplete**: Bash-completions of commands and options\n- **Highly configurable**: Sensible defaults, lots of choises\n- **Easy setup**: Download centry, create a manifest file and you are good to go\n- **Generated documentation**: Markdown documentation generated from your CLI\n\n## Full documentation\n\n- v1 - [./docs/index.md](./docs/index.md)\n\n## Install\n\n### Mac\n\n```bash\ncurl -L https://github.com/kristofferahl/go-centry/releases/download/v1.0.0/go-centry_1.0.0_Darwin_x86_64.tar.gz | tar -xzv -C /usr/local/bin/\n```\n\n### Linux\n\n```bash\ncurl -L https://github.com/kristofferahl/go-centry/releases/download/v1.0.0/go-centry_1.0.0_Linux_x86_64.tar.gz | tar -xzv -C /usr/local/bin/\n```\n\n## Getting started\n\n**The documentation and examples below assumes that**\n\n1. You are running `bash` version 3.2 or later\n1. You have \"installed\" the `go-centry_*` binary for your OS and made it available in your path as `mycli` (by renaming the file)\n1. You have created an empty directory to hold your commands and manifest file\n\n## Setup\n\n1. Create the manifest file for the CLI and name it `centry.yaml` by running the following command in your shell.\n   ```bash\n   echo \"commands: []\n   config:\n     name: mycli\" \u003e centry.yaml\n   ```\n2. Verify that it's working by running\n   ```\n   mycli --help\n   ```\n   This should display the contextual help for the cli and the name **mycli** at the top.\n\n## The manifest file\n\nThis is where you define root level commands and options, do configuration overrides and import scripts to be available for all your commands.\n\nBy default, `centry` will look for a `centry.yaml` file in the **current directory**. You may change the location and name of the manifest file but this requires you to let centry know where to find it. This can be done by setting the environment variable `CENTRY_FILE` or by way of passing `--centry-file \u003cpath\u003e` as the **first** argument.\n\n## Commands\n\nIn `centry`, commands are simple shell scripts with a matching function name in it.\n\nLet's start by creating a file called `hello.sh` with the following content.\n\n_`// file: hello.sh`_\n\n```\n#!/usr/bin/env bash\n\nhello() {\n  echo 'Hello centry'\n}\n```\n\nBefore you can use the `hello` function as a command, you need to tell `centry` where to find it. Open `centry.yaml` in an editor of choise and modify it to look like this:\n\n_`// file: centry.yaml`_\n\n```yaml\ncommands:\n  - name: hello\n    path: ./hello.sh\n    description: Says hello\n\nconfig:\n  name: mycli\n```\n\nYou should now be able to able to run the command.\n\n```bash\nmycli hello ↵\nHello centry\n```\n\n## Options\n\nIn `centry`, options are flags you use to pass named arguments to your command functions. This enables easier discovery of your cli and less friction for users. They may be specified in long (`--option`) or short (`-o`) form.\n\nLet's add a `--name` option to the hello command. This is done by adding `annotations` in your script. Edit `hello.sh` to look like this.\n\n_`// file: hello.sh`_\n\n```\n#!/usr/bin/env bash\n\n# centry.cmd[hello].option[name]/type=string\nhello() {\n  echo \"Hello ${NAME}\"\n}\n```\n\nRunning the `hello` command again would look like this\n\n```bash\nmycli hello ↵\nHello\n```\n\nTo pass a name to be echoed back to you, call the command with the `--name` option.\n\n```bash\nmycli hello --name William ↵\nHello William\n```\n\nIf you want to add a description for the `--name` option you should add an additional annotation to the `hello.sh` file.\n\n_`// file: hello.sh`_\n\n```\n#!/usr/bin/env bash\n\n# centry.cmd[hello].option[name]/type=string\n# centry.cmd[hello].option[name]/description=Name to be greeted with\nhello() {\n  echo \"Hello ${NAME}\"\n}\n```\n\nDisplaying the contextual help (using the `--help` option) should now look something like this.\n\n```bash\nmycli hello --help ↵\nNAME:\n   mycli hello - Says hello\n\nUSAGE:\n   mycli hello [command options] [arguments...]\n\nOPTIONS:\n   --name value  Name to be greeted with\n   --help, -h    Show help (default: false)\n```\n\n## Arguments\n\nA command may also accept any number of arguments. All arguments not matching an option of a command will be passed on to the function.\n\n_`// file: hello.sh`_\n\n```\n#!/usr/bin/env bash\n\n# centry.cmd[hello].option[name]/type=string\n# centry.cmd[hello].option[name]/description=Name to be greeted with\nhello() {\n  echo \"Hello ${NAME}\"\n  echo \"Arguments (${#*}): ${*}\"\n}\n```\n\nNOTE: Arguments must always be passed after the last option.\n\n```bash\nmycli hello --name William arg1 arg2 ↵\nHello William\nArguments (2): arg1 arg2\n```\n\n## Autocomplete\n\n**NOTE: Only available for Bash**\n\nTo make discovery of `mycli` easier, we may want to enable bash completions. Follow the steps below to set it up.\n\n```bash\ncurl -o bash_autocomplete https://raw.githubusercontent.com/kristofferahl/go-centry/master/bash_autocomplete\nPROG=mycli source bash_autocomplete\n```\n\nNow, let try it out by typing `mycli` followed by a space and then hit `tab`. This will display any command available at the root level. If there is only one, the command name will be autocompleted. It works for options too.\n\n```bash\nmycli -- ➡\n--centry-config-log-level  --centry-quiet             --help\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristofferahl%2Fgo-centry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristofferahl%2Fgo-centry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristofferahl%2Fgo-centry/lists"}