{"id":16179766,"url":"https://github.com/bep/simplecobra","last_synced_at":"2026-02-15T17:42:19.595Z","repository":{"id":158036977,"uuid":"633761772","full_name":"bep/simplecobra","owner":"bep","description":"A simpler API for the popular Cobra CLI.","archived":false,"fork":false,"pushed_at":"2026-01-13T20:42:57.000Z","size":51,"stargazers_count":57,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-11T01:47:44.336Z","etag":null,"topics":["cli","command-line-tool","go-library","golang"],"latest_commit_sha":null,"homepage":"","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/bep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["bep"]}},"created_at":"2023-04-28T08:11:25.000Z","updated_at":"2026-01-13T20:43:03.000Z","dependencies_parsed_at":"2023-11-27T10:35:44.874Z","dependency_job_id":"32c1cb12-694c-4117-b359-9929c199fca9","html_url":"https://github.com/bep/simplecobra","commit_stats":null,"previous_names":["bep/cobrakai"],"tags_count":9,"template":false,"template_full_name":"bep/golibtemplate","purl":"pkg:github/bep/simplecobra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fsimplecobra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fsimplecobra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fsimplecobra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fsimplecobra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bep","download_url":"https://codeload.github.com/bep/simplecobra/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bep%2Fsimplecobra/sbom","scorecard":{"id":234001,"data":{"date":"2025-08-11","repo":{"name":"github.com/bep/simplecobra","commit":"57fa80cdf5a5fe570365fa295dab6e4b5bc9504a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/test.yml:6","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":5,"reason":"dependency not pinned by hash detected -- score normalized to 5","details":["Warn: goCommand not pinned by hash: .github/workflows/test.yml:22","Warn: goCommand not pinned by hash: .github/workflows/test.yml:25","Info:   2 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 14 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T05:17:12.408Z","repository_id":158036977,"created_at":"2025-08-17T05:17:12.408Z","updated_at":"2025-08-17T05:17:12.408Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29486036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","command-line-tool","go-library","golang"],"created_at":"2024-10-10T05:43:59.231Z","updated_at":"2026-02-15T17:42:19.559Z","avatar_url":"https://github.com/bep.png","language":"Go","funding_links":["https://github.com/sponsors/bep"],"categories":["Go"],"sub_categories":[],"readme":"[![Tests on Linux, MacOS and Windows](https://github.com/bep/simplecobra/workflows/Test/badge.svg)](https://github.com/bep/simplecobra/actions?query=workflow:Test)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bep/simplecobra)](https://goreportcard.com/report/github.com/bep/simplecobra)\n[![codecov](https://codecov.io/gh/bep/simplecobra/branch/master/graph/badge.svg)](https://codecov.io/gh/bep/simplecobra)\n[![GoDoc](https://godoc.org/github.com/bep/simplecobra?status.svg)](https://godoc.org/github.com/bep/simplecobra)\n\nSo, [Cobra](https://github.com/spf13/cobra) is a Go CLI library with a feature set that's hard to resist for bigger applications (autocompletion, docs and man pages auto generation etc.). But it's also complex to use beyond the simplest of applications. This package was built to help rewriting [Hugo's](https://github.com/gohugoio/hugo) commands package to something that's easier to understand and maintain.\n\nI welcome suggestions to improve/simplify this further, but the core idea is that the command graph gets built in one go with a tree of struct pointers implementing a simple `Commander` interface:\n\n```go\n// Commander is the interface that must be implemented by all commands.\ntype Commander interface {\n\t// The name of the command.\n\tName() string\n\n\t// Init is called when the cobra command is created.\n\t// This is where the flags, short and long description etc. can be added.\n\tInit(*Commandeer) error\n\n\t// PreRun called on all ancestors and the executing command itself, before execution, starting from the root.\n\t// This is the place to evaluate flags and set up the this Commandeer.\n\t// The runner Commandeer holds the currently running command, which will be PreRun last.\n\tPreRun(this, runner *Commandeer) error\n\n\t// The command execution.\n\tRun(ctx context.Context, cd *Commandeer, args []string) error\n\n\t// Commands returns the sub commands, if any.\n\tCommands() []Commander\n}\n```\n\nThe `Init` method allows for flag compilation, referencing the parent and root etc. If needed, the full Cobra command is still available.\n\nThere's a runnable [example](https://pkg.go.dev/github.com/bep/simplecobra#example-package) in the documentation, but the gist of it is:\n\n```go\nfunc main() {\n\trootCmd := \u0026rootCommand{name: \"root\",\n\t\tcommands: []simplecobra.Commander{\n\t\t\t\u0026lvl1Command{name: \"foo\"},\n\t\t\t\u0026lvl1Command{name: \"bar\",\n\t\t\t\tcommands: []simplecobra.Commander{\n\t\t\t\t\t\u0026lvl2Command{name: \"baz\"},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tx, err := simplecobra.New(rootCmd)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tcd, err := x.Execute(context.Background(), []string{\"bar\", \"baz\", \"--localFlagName\", \"baz_local\", \"--persistentFlagName\", \"baz_persistent\"})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// These are wired up in Init().\n\tlvl2 := cd.Command.(*lvl2Command)\n\tlvl1 := lvl2.parentCmd\n\troot := lvl1.rootCmd\n\n\tfmt.Printf(\"Executed %s.%s.%s with localFlagName %s and and persistentFlagName %s.\\n\", root.name, lvl1.name, lvl2.name, lvl2.localFlagName, root.persistentFlagName)\n}\n```\n\n\n## Differences to Cobra\n\nYou have access to the `*cobra.Command` pointer so there's not much you cannot do with this project compared to the more low-level Cobra, but there's one small, but important difference:\n\nCobra only treats the first level of misspelled commands as an `unknown command` with \"Did you mean this?\" suggestions, see [see this issue](https://github.com/spf13/cobra/pull/1500) for more context. The reason for this is the ambiguity between sub-command names and command arguments, but that is throwing away a very useful feature for a not very good reason. We recently rewrote [Hugo's CLI](https://github.com/gohugoio/hugo) using this package, and found only one sub command that needed to be adjusted to avoid this ambiguity.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbep%2Fsimplecobra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbep%2Fsimplecobra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbep%2Fsimplecobra/lists"}