{"id":21476837,"url":"https://github.com/phogolabs/cli","last_synced_at":"2025-03-17T08:18:59.861Z","repository":{"id":44999759,"uuid":"163818372","full_name":"phogolabs/cli","owner":"phogolabs","description":"A simple package for building command line applications in Go","archived":false,"fork":false,"pushed_at":"2024-01-08T16:49:54.000Z","size":615,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T17:45:56.077Z","etag":null,"topics":["cli","golang","s3","vault-client"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/phogolabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"2019-01-02T09:06:28.000Z","updated_at":"2023-08-22T08:44:57.000Z","dependencies_parsed_at":"2024-06-21T13:07:46.542Z","dependency_job_id":"05162bd6-a308-4d69-a576-e826cc4946fc","html_url":"https://github.com/phogolabs/cli","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/phogolabs%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phogolabs","download_url":"https://codeload.github.com/phogolabs/cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997126,"owners_count":20380981,"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":["cli","golang","s3","vault-client"],"created_at":"2024-11-23T11:10:35.006Z","updated_at":"2025-03-17T08:18:59.824Z","avatar_url":"https://github.com/phogolabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLI\n\n[![Documentation][godoc-img]][godoc-url]\n![License][license-img]\n[![Build Status][action-img]][action-url]\n[![Coverage][codecov-img]][codecov-url]\n[![Go Report Card][report-img]][report-url]\n\nA simple package for building command line applications in Go. The API is\ninfluenced by https://github.com/urfave/cli package, but it is way more\nflexible. It provides the following features:\n\n- More extensible flag types such as URL, IP, JSON, YAML and so on. For more information see the [docs][godoc-url]\n- Data providers that allow setting the flag's value from different sources such as command line arguments, environment variables and [etc](https://github.com/hairyhenderson/go-fsimpl).\n- Data conversion that allow conversion of data to a compatible data type accepted by the declared flag\n\n## Installation\n\nMake sure you have a working Go environment. Go version 1.16.x is supported.\n\n[See the install instructions for Go](http://golang.org/doc/install.html).\n\nTo install CLI, simply run:\n\n```\n$ go get github.com/phogolabs/cli\n```\n\n## Getting Started\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"syscall\"\n\n\t\"github.com/phogolabs/cli\"\n)\n\nvar flags = []cli.Flag{\n\t\u0026cli.YAMLFlag{\n\t\tName:     \"config\",\n\t\tUsage:    \"Application Config\",\n\t\tPath:     \"/etc/app/default.conf\",\n\t\tEnvVar:   \"APP_CONFIG\",\n\t\tValue:    \u0026Config{},\n\t\tRequired: true,\n\t},\n\t\u0026cli.StringFlag{\n\t\tName:     \"listen-addr\",\n\t\tUsage:    \"Application TCP Listen Address\",\n\t\tEnvVar:   \"APP_LISTEN_ADDR\",\n\t\tValue:    \":8080\",\n\t\tRequired: true,\n\t},\n}\n\nfunc main() {\n\tapp := \u0026cli.App{\n\t\tName:      \"prana\",\n\t\tHelpName:  \"prana\",\n\t\tUsage:     \"Golang Database Manager\",\n\t\tUsageText: \"prana [global options]\",\n\t\tVersion:   \"1.0-beta-04\",\n\t\tFlags:     flags,\n\t\tAction:    run,\n\t\tSignals:   []os.Signal{syscall.SIGTERM},\n\t\tOnSignal:  signal,\n\t}\n\n\tapp.Run(os.Args)\n}\n\n// run executes the application\nfunc run(ctx *cli.Context) error {\n\tfmt.Println(\"Application started\")\n\treturn nil\n}\n\n// signal handles OS signal\nfunc signal(ctx *cli.Context, signal os.Signal) error {\n\tfmt.Println(\"Application signal\", signal)\n\treturn nil\n}\n```\n\n## Validation\n\nYou can set the `Required` field to `true` if you want to make some flags\nmandatory. If you need some customized validation, you can create a custom\nvalidator in the following way:\n\nAs a struct that has a `Validate` function:\n\n``` golang\ntype Validator struct{}\n\nfunc (v *Validator) Validate(ctx *cli.Context, value interface{}) error {\n\t//TODO: your validation logic\n\treturn nil\n}\n```\n\nThen you can set the validator like that:\n\n```golang\nvar flags = []cli.Flag{\n\t\u0026cli.StringFlag{\n\t\tName:      \"name\",\n\t\tEnvVar:    \"APP_NAME\",\n\t\tValidator: \u0026Validator{},\n\t},\n}\n```\n\n## Contributing\n\nWe are open for any contributions. Just fork the\n[project](https://github.com/phogolabs/cli).\n\n[report-img]: https://goreportcard.com/badge/github.com/phogolabs/cli\n[report-url]: https://goreportcard.com/report/github.com/phogolabs/cli\n[codecov-url]: https://codecov.io/gh/phogolabs/cli\n[codecov-img]: https://codecov.io/gh/phogolabs/cli/branch/master/graph/badge.svg\n[action-img]: https://github.com/phogolabs/cli/workflows/main/badge.svg\n[action-url]: https://github.com/phogolabs/cli/actions\n[godoc-url]: https://godoc.org/github.com/phogolabs/cli\n[godoc-img]: https://godoc.org/github.com/phogolabs/cli?status.svg\n[license-img]: https://img.shields.io/badge/license-MIT-blue.svg\n[software-license-url]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphogolabs%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphogolabs%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphogolabs%2Fcli/lists"}