{"id":17920889,"url":"https://github.com/eth-p/go-clout","last_synced_at":"2025-03-24T00:32:35.888Z","repository":{"id":57615249,"uuid":"381513359","full_name":"eth-p/go-clout","owner":"eth-p","description":"An opinionated package that helps you print user-friendly output messages from your Go command line applications.","archived":false,"fork":false,"pushed_at":"2024-06-20T04:35:25.000Z","size":47,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T16:39:55.628Z","etag":null,"topics":[],"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/eth-p.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":"2021-06-29T22:34:57.000Z","updated_at":"2024-06-20T03:11:35.000Z","dependencies_parsed_at":"2022-09-10T23:56:58.208Z","dependency_job_id":null,"html_url":"https://github.com/eth-p/go-clout","commit_stats":null,"previous_names":["eth-p/clout"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fgo-clout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fgo-clout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fgo-clout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eth-p%2Fgo-clout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eth-p","download_url":"https://codeload.github.com/eth-p/go-clout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221780809,"owners_count":16879118,"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-10-28T20:29:31.100Z","updated_at":"2024-10-28T20:29:31.794Z","avatar_url":"https://github.com/eth-p.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go.eth-p.dev/clout\n(**C**ommand **L**ine **Out**put)\n\n`clout` is a package that helps you print user-friendly output messages from your Go command line applications.\n\n\n## Installation\n\n```go\nimport (\n    \"go.eth-p.dev/clout\"\n)\n```\n\n## Why clout?\n\nClout helps you print readable and consistent messages using a familiar `klog`-like API. It's unobtrusive, and designed to enable you to write command line tools without having to worry about the specifics of ANSI colors or stdout/stderr best practices.\n\n### Messages Types\n\nInstead of asking you to figure out which output stream a message should be destined for, `clout` provides with you different types of messages that you can print:\n\n|Constant|Usage|\n|:--|:--|\n|`Status`|An update to the program's current status.|\n|`Info`|An informational message.|\n|`Warning`|A warning about a potential issue.|\n|`Deprecation`|A warning about a feature which will be removed or unsupported in the future.|\n|`Error`|A severe error.|\n\nBy default, `clout` will direct these messages into an appropriate output stream. Warning and error messages will go to the standard error, and all other messages will go to the standard output.  \n\n### Configurable Verbosity\n\nJust like `klog`, `clout` supports different verbosity levels. If you want to provide extra debug information without littering the code with `if`-statements, you can do that:\n\n```go\nclout.V(2).Infof(\"Processing %s\", file)            // Visible by default.\nclout.V(4).Statusf(\"%s: Unmarshalling yaml\", file) // Only visible with verbosity 4 or higher.\n```\n\n#### Best Practices\n\nThe following table shows the best practices for using verbosity levels. It's based on the [Kubernetes logging best practices](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md):\n\n|Level|For|\n|:-:|:--|\n|V(0)|Programmer errors, logging extra info about a panic, cli argument handling.|\n|V(1)|Information about config, errors.|\n|**V(2)**|System state, log messages.|\n|V(3)|Extended info about system state changes.|\n|V(4)|Logging in \"thorny parts of code\".|\n|V(5)|Trace level verbosity.|\n\n### Color Support\n\nWhen your terminal supports colors, giant walls of plain text can be unwieldy. `clout` helps you with that by providing color support (Linux/MacOS only) with no extra burden on you:\n\n- Warning messages will be prefixed with \"warning: \" and automatically colored yellow.\n- Deprecation messages will be prefixed with \"deprecated: \" and automatically colored yellow.\n- Error messages will be prefixed with \"error: \" and automatically colored red.\n\nAnd if you have any text that you feel should be highlighted to stand out (e.g. paths)? You can simply wrap parameters in a `Highlight`, and `clout` will handle it. \n\n#### Conditional Colors\n\nBest of all, colors are enabled conditionally. If someone pipes your command's output, colors will be disabled automatically. `clout` even supports the `NO_COLOR` standard ;)\n\n\n\n## Example\n\n```go\nimport (\n    \"go.eth-p.dev/clout\"\n    \"go.eth-p.dev/clout/pkg/highlight\"\n)\n\nfunc main() {\n    clout.V(2).Infof(\"Initializing application...\")\n    // -\u003e Initializing application...\n    \n    clout.V(3).Info(\"Args: %#v\", os.Args)\n    // This won't print anything, because the default verbosity is level 2.\n\t\n    if len(os.Args) != 2 {\n        clout.V(1).Error(\"not enough arguments\")\n        // -\u003e error: not enough arguments\n        return\n    }\n    \n    clout.V(2).Infof(\"Hello, %s.\", highlight.Cyan(os.Args[1]))\n    // -\u003e Hello, SOME_EXECUTABLE_NAME\n    // On supported systems, SOME_EXECUTABLE_NAME will be cyan.\n}\n```\n\nFor more detailed examples, feel free to check out the [examples directory](examples).\n\n\n## License\n\n[MIT License](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feth-p%2Fgo-clout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feth-p%2Fgo-clout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feth-p%2Fgo-clout/lists"}