{"id":13394029,"url":"https://github.com/tcnksm/gcli","last_synced_at":"2025-12-16T20:49:24.422Z","repository":{"id":17987299,"uuid":"20994449","full_name":"tcnksm/gcli","owner":"tcnksm","description":"The easy way to build Golang command-line application.","archived":false,"fork":false,"pushed_at":"2017-11-20T04:20:18.000Z","size":5460,"stargazers_count":919,"open_issues_count":19,"forks_count":75,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-10-21T08:47:23.196Z","etag":null,"topics":["cli-framework","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"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/tcnksm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-19T09:10:15.000Z","updated_at":"2025-09-20T17:39:35.000Z","dependencies_parsed_at":"2022-09-12T02:31:34.939Z","dependency_job_id":null,"html_url":"https://github.com/tcnksm/gcli","commit_stats":null,"previous_names":["tcnksm/cli-init"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tcnksm/gcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcnksm%2Fgcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcnksm%2Fgcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcnksm%2Fgcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcnksm%2Fgcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcnksm","download_url":"https://codeload.github.com/tcnksm/gcli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcnksm%2Fgcli/sbom","scorecard":{"id":870708,"data":{"date":"2025-08-11","repo":{"name":"github.com/tcnksm/gcli","commit":"7eb950507e5af1cd41c906e044dd23945e745696"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Code-Review","score":4,"reason":"Found 8/20 approved changesets -- score normalized to 4","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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Maintained","score":0,"reason":"0 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":"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":"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":"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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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":"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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":["Info: Possibly incomplete results: error parsing shell code: a command can only contain words and redirects; encountered (: skeleton/resource/tmpl/bash/main.sh.tmpl:0"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 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-24T04:07:32.333Z","repository_id":17987299,"created_at":"2025-08-24T04:07:32.333Z","updated_at":"2025-08-24T04:07:32.333Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27771138,"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","status":"online","status_checked_at":"2025-12-16T02:00:10.477Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-framework","golang"],"created_at":"2024-07-30T17:01:06.439Z","updated_at":"2025-12-16T20:49:24.403Z","avatar_url":"https://github.com/tcnksm.png","language":"Go","readme":"gcli\n====\n\n[![GitHub release](http://img.shields.io/github/release/tcnksm/gcli.svg?style=flat-square)][release]\n [![Travis](https://img.shields.io/travis/tcnksm/gcli.svg?style=flat-square)][travis]\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]\n[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs]\n\n[release]: https://github.com/tcnksm/gcli/releases\n[travis]: https://travis-ci.org/tcnksm/gcli\n[license]: https://github.com/tcnksm/gcli/blob/master/LICENSE\n[godocs]: http://godoc.org/github.com/tcnksm/gcli\n\n`gcli` generates a skeleton (codes and its directory structure) you need to start building Command Line Interface (CLI) tool by Golang right out of the box. You can use your favorite [CLI framework](#frameworks).\n\n## Why ?\n\nWhy you need `gcli`? Because you should focus on writing core function of CLI, not on interface. During developing CLI tool by Golang, you may find you're writing the chunk of [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) for interfaces. Stop writing the same codes every time. `gcli` generates them and save you a large amount of time by writing such code. This is like [Rails scaffold](http://guides.rubyonrails.org/command_line.html#rails-generate). Not only that, `gcli` know the best practices of golang CLI framework library which you want to use. Generated codes follows the most ideal way of using that framework, and you don't need to know about that. See the [frameworks](#frameworks) it supports now. \n\n## Demo\n\nThe following demo shows creating `todo` CLI application which has `add`, `list` and `delete` command with [mitchellh/cli](https://github.com/mitchellh/cli) (Which is used for [Hashicorp](https://hashicorp.com/) products) with **one command**. As you can see, the generated codes are `go build`-able from beginning. \n\n![gif](/doc/gif/gcli-new.gif)\n\nAnd this [video](https://vimeo.com/142134929) shows creating same `todo` CLI application with `design` \u0026 `apply` commands. This is the other way to start building new CLI application. First, it starts with creating design file by `design` command. In this file, you can define, CLI name, description of the CLI , framework you want to use, and commands \u0026 flags with its usages. After editing, it executes `apply` command to generating a project from that design file. \n\n## Usage\n\n`gcli` is single command-line application. This application then takes subcommands. To check the all available commands,\n\n```bash\n$ gcli help\n```\n\nTo get help for any specific subcommand, run it with the `-h` flag.\n\n`gcli` has 2 main subcommand to generate the project. The one is the `new` command, the other is the `design` \u0026 `apply` commands. The former is for generating the project by command line one-liner, the latter is for when you want to design it in your editor before generating (It generates design file and you can generate project based on it). The following section explain, how to use these commands.\n\n### `new` command\n\nThe `new` command tells gcli to generate CLI project with command-line one-liner,\n\n```bash\n$ gcli new [options] NAME\n```\n\nYou must provides project name (`NAME`), the name will be the directory name it includes all codes and be the default binary name. By default, `gcli` creates a project under `$GOPATH/github.com/\u003cusername\u003e` (If you don't provide username via option, it uses `github.user` or `user.name` in `.gitconfig` file). In option, you can set subcommand or flag it has and its description. You can also set your favorite [CLI framework](#frameworks) there. The followings are all available opntions,\n\n```bash\n-command=name, -c           Command name which you want to add.\n                            This is valid only when cli pacakge support commands.\n                            This can be specified multiple times. Synopsis can be\n                            set after \":\". Namely, you can specify command by\n                            -command=NAME:SYNOPSYS. Only NAME is required.\n                            You can set multiple variables at same time with \",\"\n                            separator.\n\n-flag=name, -f              Global flag option name which you want to add.\n                            This can be specified multiple times. By default, flag type\n                            is string and its description is empty. You can set them,\n                            with \":\" separator. Namaly, you can specify flag by\n                            -flag=NAME:TYPE:DESCIRPTION. Order must be flow  this and\n                            TYPE must be string, bool or int. Only NAME is required.\n                            You can set multiple variables at same time with \",\"\n                            separator.\n\n-framework=name, -F         Cli framework name. By default, gcli use \"codegangsta/cli\"\n                            To check cli framework you can use, run 'gcli list'.\n                            If you set invalid framework, it will be failed.\n\n-owner=name, -o             Command owner (author) name. This value is also used for\n                            import path name. By default, owner name is extracted from\n                            ~/.gitconfig variable.\n\n-skip-test, -T              Skip generating *_test.go file. By default, gcli generates\n                            test file If you specify this flag, gcli will not generate\n                            test files.\n```\n\nFor example, to `todo` CLI application which has `add`, `list` and `delete` command with [mitchellh/cli](https://github.com/mitchellh/cli),\n\n```bash\n$ gcli new -F mitchellh_cli -c add -c list -c delete todo\n```\n\n### `design` \u0026 `apply` command\n\nThe `design` command tells gcli to prepare design template file ([`.toml`](https://github.com/toml-lang/toml)). The design file defines all necessary information to generate CLI application. Some fields are filled with the ideal default value, and some have empty value. You can fill that empty filed with your favorite editor with thinking like what interface that should have or description of that and so on. You can see sample template file [`sample.toml`](/sample.toml). \n\nAfter design, use `apply` command and tells gcli to generate CLI project based on the design file. The following describes this workflow. \n\nFirst, generate design template file by `design` command, \n\n```bash\n$ gcli design [options] NAME\n```\nYou must provides project name (`NAME`). In option, you can set subcommand or flag it has and its description. You can also set your favorite [CLI framework](#frameworks) there. You can edit these values in design file later. \n\nThen, edit design file by your favorite `$EDITOR`.\n\n```bash\n$ $EDITOR \u003cNAME\u003e-design.toml\n```\n\nAfter that validate design by `validate` command to check required fields are filled, \n\n```bash\n$ gcli validate \u003cNAME\u003e-design.toml\n```\n\nFinnaly, generate CLI project with that design file by `apply` command, \n\n```bash\n$ gcli apply \u003cNAME\u003e-desigon.toml\n```\n\nThe video for this workflow is available on [Vimeo](https://vimeo.com/142134929). \n\n## Frameworks\n\nThere are many framework (package) for buidling command line application by golang. For example, one of the most famous frameworks is [codegangsta/cli](https://github.com/codegangsta/cli). The framework helps you not writing many codes. But still you need to write many boilerplate code for that framework. And there are different way to use that framework and learning the ideal way to use is waste of time. gcli writes out with following the best practice for that framework (learn from famous tool that is built with that framework). \n\n`gcli` can generate 2 types of CLI pattern. The one is [*sub-command pattern*](#sub-command), the other is [*flag pattern*](#flag). The former is flexible and you can add many behavior in one command application. The later is for simple application. You can check the all available frameworks by `list` command,\n\n```bash\n$ gcli list\n```\n\nTo change framework, you can use `-framework` or `-F` option with the framework name. This option can be used for `new`, `design` and `apply` command. By default, [codegangsta_cli](https://github.com/codegangsta/cli) will be used. \n\nThe following section will explain [*sub-command pattern*](#sub-command) and [*flag pattern*](#flag). \n\n### Sub-Command\n\n*Sub-Command pattern* is the pattern that executable takes sub-command for change its behavior. `git` command is one example for this pattern. It takes `push`, `pull` subcommands. `gcli` is also this pattern. `gcli` supports the following frameworks for the command pattern.\n\n|Name|Sample projects|\n|:-:|:-:| \n|[codegangsta_cli](https://github.com/codegangsta/cli) | [docker machine](https://github.com/docker/machine) | \n|[mitchellh_cli](https://github.com/mitchellh/cli)| [consul](https://github.com/hashicorp/consul), [terraform](https://github.com/hashicorp/terraform)| \n|[go_cmd](https://github.com/golang/go/blob/master/src/cmd/go/main.go#L30#L51)| [go](https://golang.org/cmd/go/)| \n\n([go_cmd](https://github.com/golang/go/blob/master/src/cmd/go/main.go#L30#L51) is not framework. It only uses standard package. It generates same struct and functions that `go` command uses.)\n\n### Flag\n\n*Flag pattern* is the pattern that executable has flag options for changing its behavior. For example, `grep` command is this pattern. Now `gcli` only supports the official [flag](https://golang.org/pkg/flag/) package for this pattern.\n\nFor example, to create command it has `-ignore-case` option and `context` option (your own `grep`),\n\n```bash\n$ gcli new -F flag -flag=i:Bool -flag=C:Int grep\n```\n\n## Installation\n\nTo install, use `go get` and `make install`. We tag versions so feel free to checkout that tag and compile.\n\n```bash\n$ go get -d github.com/tcnksm/gcli\n$ cd $GOPATH/src/github.com/tcnksm/gcli\n$ make install \n```\n\n## Contribution\n\n1. Fork ([https://github.com/tcnksm/gcli/fork](https://github.com/tcnksm/gcli/fork))\n1. Create a feature branch\n1. Commit your changes\n1. Rebase your local changes against the master branch\n1. Run test suite with the `make test` command and confirm that it passes\n1. Create a new Pull Request\n\n## Author\n\n[Taichi Nakashima](https://github.com/tcnksm)\n","funding_links":[],"categories":["Go","Command Line","命令行","golang","\u003cspan id=\"命令行-command-line\"\u003e命令行 Command Line\u003c/span\u003e"],"sub_categories":["Standard CLI","标准CLI","标准命令行交互","標準命令行交互"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcnksm%2Fgcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcnksm%2Fgcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcnksm%2Fgcli/lists"}