{"id":13393933,"url":"https://github.com/spf13/cobra","last_synced_at":"2025-05-12T17:39:02.443Z","repository":{"id":37405385,"uuid":"12574344","full_name":"spf13/cobra","owner":"spf13","description":"A Commander for modern Go CLI interactions","archived":false,"fork":false,"pushed_at":"2025-03-11T12:56:36.000Z","size":2026,"stargazers_count":40318,"open_issues_count":312,"forks_count":2936,"subscribers_count":369,"default_branch":"main","last_synced_at":"2025-05-05T15:08:33.326Z","etag":null,"topics":["cli","cli-app","cobra","cobra-generator","cobra-library","command","command-cobra","command-line","commandline","go","golang","golang-application","golang-library","posix","posix-compliant-flags","subcommands"],"latest_commit_sha":null,"homepage":"https://cobra.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spf13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-09-03T20:40:26.000Z","updated_at":"2025-05-05T13:38:51.000Z","dependencies_parsed_at":"2023-10-16T03:53:24.366Z","dependency_job_id":"f3155716-142a-4190-b118-b7036bfdb52f","html_url":"https://github.com/spf13/cobra","commit_stats":{"total_commits":940,"total_committers":319,"mean_commits":2.946708463949843,"dds":0.8797872340425532,"last_synced_commit":"3a5efaede9d389703a792e2f7bfe3a64bc82ced9"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spf13%2Fcobra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spf13%2Fcobra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spf13%2Fcobra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spf13%2Fcobra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spf13","download_url":"https://codeload.github.com/spf13/cobra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253008753,"owners_count":21839699,"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","cli-app","cobra","cobra-generator","cobra-library","command","command-cobra","command-line","commandline","go","golang","golang-application","golang-library","posix","posix-compliant-flags","subcommands"],"created_at":"2024-07-30T17:01:02.913Z","updated_at":"2025-05-12T17:39:02.433Z","avatar_url":"https://github.com/spf13.png","language":"Go","funding_links":[],"categories":["Go","Popular","HarmonyOS","开源类库","CLI","Commandline Parser","Command Line","Misc","命令行","Programming","Uncategorized","CLI frameworks","Open source library","\u003cspan id=\"命令行-command-line\"\u003e命令行 Command Line\u003c/span\u003e","语言资源库","前端开发框架及项目","AI 时代全栈工具链 (2026 深度更新)","Tools","cli","Credits","命令行工具开发库","命令行工具### 标准 CLI`用于创建一个标准命令行应用程序的库`","命令行工具","Libraries","Build Automation","Repositories","Go 🐹","[Go](https://go.dev/)","Command Line Interface (CLI)"],"sub_categories":["Windows Manager","命令行","Standard CLI","标准CLI","Golang","Uncategorized","Command Line","Go","go","其他_文本生成、文本对话","CLI 基础框架与 Agent 原型 (CLI \u0026 Agent Prototypes)","标准 CLI","標準命令行交互","Useful awesome list for Dotnet cli","标准命令行交互"],"readme":"\n![cobra logo](https://github.com/user-attachments/assets/cbc3adf8-0dff-46e9-a88d-5e2d971c169e)\n\nCobra is a library for creating powerful modern CLI applications.\n\nCobra is used in many Go projects such as [Kubernetes](https://kubernetes.io/),\n[Hugo](https://gohugo.io), and [GitHub CLI](https://github.com/cli/cli) to\nname a few. [This list](site/content/projects_using_cobra.md) contains a more extensive list of projects using Cobra.\n\n[![](https://img.shields.io/github/actions/workflow/status/spf13/cobra/test.yml?branch=main\u0026longCache=true\u0026label=Test\u0026logo=github%20actions\u0026logoColor=fff)](https://github.com/spf13/cobra/actions?query=workflow%3ATest)\n[![Go Reference](https://pkg.go.dev/badge/github.com/spf13/cobra.svg)](https://pkg.go.dev/github.com/spf13/cobra)\n[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra)\n[![Slack](https://img.shields.io/badge/Slack-cobra-brightgreen)](https://gophers.slack.com/archives/CD3LP1199)\n\u003chr\u003e\n\u003cdiv align=\"center\" markdown=\"1\"\u003e\n   \u003csup\u003eSupported by:\u003c/sup\u003e\n   \u003cbr\u003e\n   \u003cbr\u003e\n   \u003ca href=\"https://www.warp.dev/cobra\"\u003e\n      \u003cimg alt=\"Warp sponsorship\" width=\"400\" src=\"https://github.com/user-attachments/assets/ab8dd143-b0fd-4904-bdc5-dd7ecac94eae\"\u003e\n   \u003c/a\u003e\n\n### [Warp, the AI terminal for devs](https://www.warp.dev/cobra)\n[Try Cobra in Warp today](https://www.warp.dev/cobra)\u003cbr\u003e\n\n\u003c/div\u003e\n\u003chr\u003e\n\n# Overview\n\nCobra is a library providing a simple interface to create powerful modern CLI\ninterfaces similar to git \u0026 go tools.\n\nCobra provides:\n* Easy subcommand-based CLIs: `app server`, `app fetch`, etc.\n* Fully POSIX-compliant flags (including short \u0026 long versions)\n* Nested subcommands\n* Global, local and cascading flags\n* Intelligent suggestions (`app srver`... did you mean `app server`?)\n* Automatic help generation for commands and flags\n* Grouping help for subcommands\n* Automatic help flag recognition of `-h`, `--help`, etc.\n* Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell)\n* Automatically generated man pages for your application\n* Command aliases so you can change things without breaking them\n* The flexibility to define your own help, usage, etc.\n* Optional seamless integration with [viper](https://github.com/spf13/viper) for 12-factor apps\n\n# Concepts\n\nCobra is built on a structure of commands, arguments \u0026 flags.\n\n**Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions.\n\nThe best applications read like sentences when used, and as a result, users\nintuitively know how to interact with them.\n\nThe pattern to follow is\n`APPNAME VERB NOUN --ADJECTIVE`\n    or\n`APPNAME COMMAND ARG --FLAG`.\n\nA few good real world examples may better illustrate this point.\n\nIn the following example, 'server' is a command, and 'port' is a flag:\n\n    hugo server --port=1313\n\nIn this command we are telling Git to clone the url bare.\n\n    git clone URL --bare\n\n## Commands\n\nCommand is the central point of the application. Each interaction that\nthe application supports will be contained in a Command. A command can\nhave children commands and optionally run an action.\n\nIn the example above, 'server' is the command.\n\n[More about cobra.Command](https://pkg.go.dev/github.com/spf13/cobra#Command)\n\n## Flags\n\nA flag is a way to modify the behavior of a command. Cobra supports\nfully POSIX-compliant flags as well as the Go [flag package](https://golang.org/pkg/flag/).\nA Cobra command can define flags that persist through to children commands\nand flags that are only available to that command.\n\nIn the example above, 'port' is the flag.\n\nFlag functionality is provided by the [pflag\nlibrary](https://github.com/spf13/pflag), a fork of the flag standard library\nwhich maintains the same interface while adding POSIX compliance.\n\n# Installing\nUsing Cobra is easy. First, use `go get` to install the latest version\nof the library.\n\n```\ngo get -u github.com/spf13/cobra@latest\n```\n\nNext, include Cobra in your application:\n\n```go\nimport \"github.com/spf13/cobra\"\n```\n\n# Usage\n`cobra-cli` is a command line program to generate cobra applications and command files.\nIt will bootstrap your application scaffolding to rapidly\ndevelop a Cobra-based application. It is the easiest way to incorporate Cobra into your application.\n\nIt can be installed by running:\n\n```\ngo install github.com/spf13/cobra-cli@latest\n```\n\nFor complete details on using the Cobra-CLI generator, please read [The Cobra Generator README](https://github.com/spf13/cobra-cli/blob/main/README.md)\n\nFor complete details on using the Cobra library, please read [The Cobra User Guide](site/content/user_guide.md).\n\n# License\n\nCobra is released under the Apache 2.0 license. See [LICENSE.txt](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspf13%2Fcobra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspf13%2Fcobra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspf13%2Fcobra/lists"}