Merge branch 'spf13:master' into add-asciidoc-documentation-generator

This commit is contained in:
Paul 2022-05-26 17:11:22 +10:00 committed by GitHub
commit cd93bb8ab1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 16 deletions

View file

@ -2,7 +2,7 @@
Cobra is a library for creating powerful modern CLI applications. Cobra is a library for creating powerful modern CLI applications.
Cobra is used in many Go projects such as [Kubernetes](http://kubernetes.io/), Cobra is used in many Go projects such as [Kubernetes](https://kubernetes.io/),
[Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to [Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to
name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra. name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra.
@ -28,7 +28,7 @@ Cobra provides:
* Automatically generated man pages for your application * Automatically generated man pages for your application
* Command aliases so you can change things without breaking them * Command aliases so you can change things without breaking them
* The flexibility to define your own help, usage, etc. * The flexibility to define your own help, usage, etc.
* Optional seamless integration with [viper](http://github.com/spf13/viper) for 12-factor apps * Optional seamless integration with [viper](https://github.com/spf13/viper) for 12-factor apps
# Concepts # Concepts

View file

@ -178,9 +178,7 @@ __%[1]s_handle_standard_completion_case() {
# Short circuit to optimize if we don't have descriptions # Short circuit to optimize if we don't have descriptions
if [[ $out != *$tab* ]]; then if [[ $out != *$tab* ]]; then
while IFS='' read -r comp; do IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n' compgen -W "$out" -- "$cur")
COMPREPLY+=("$comp")
done < <(IFS=$'\n' compgen -W "$out" -- "$cur")
return 0 return 0
fi fi
@ -188,6 +186,7 @@ __%[1]s_handle_standard_completion_case() {
local compline local compline
# Look for the longest completion so that we can format things nicely # Look for the longest completion so that we can format things nicely
while IFS='' read -r compline; do while IFS='' read -r compline; do
[[ -z $compline ]] && continue
# Strip any description before checking the length # Strip any description before checking the length
comp=${compline%%%%$tab*} comp=${compline%%%%$tab*}
# Only consider the completions that match # Only consider the completions that match

View file

@ -85,7 +85,7 @@ func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string)
} }
``` ```
The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](https://gohugo.io/):
```go ```go
const fmTemplate = `--- const fmTemplate = `---

View file

@ -85,7 +85,7 @@ func GenReSTCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string, str
} }
``` ```
The `filePrepender` will prepend the return value given the full filepath to the rendered ReST file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): The `filePrepender` will prepend the return value given the full filepath to the rendered ReST file. A common use case is to add front matter to use the generated documentation with [Hugo](https://gohugo.io/):
```go ```go
const fmTemplate = `--- const fmTemplate = `---

View file

@ -82,7 +82,7 @@ func GenYamlCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) str
} }
``` ```
The `filePrepender` will prepend the return value given the full filepath to the rendered Yaml file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): The `filePrepender` will prepend the return value given the full filepath to the rendered Yaml file. A common use case is to add front matter to use the generated documentation with [Hugo](https://gohugo.io/):
```go ```go
const fmTemplate = `--- const fmTemplate = `---

View file

@ -1,8 +1,8 @@
## Projects using Cobra ## Projects using Cobra
- [Arduino CLI](https://github.com/arduino/arduino-cli) - [Arduino CLI](https://github.com/arduino/arduino-cli)
- [Bleve](http://www.blevesearch.com/) - [Bleve](https://blevesearch.com/)
- [CockroachDB](http://www.cockroachlabs.com/) - [CockroachDB](https://www.cockroachlabs.com/)
- [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) - [Cosmos SDK](https://github.com/cosmos/cosmos-sdk)
- [Datree](https://github.com/datreeio/datree) - [Datree](https://github.com/datreeio/datree)
- [Delve](https://github.com/derekparker/delve) - [Delve](https://github.com/derekparker/delve)
@ -14,14 +14,14 @@
- [Github CLI](https://github.com/cli/cli) - [Github CLI](https://github.com/cli/cli)
- [GitHub Labeler](https://github.com/erdaltsksn/gh-label) - [GitHub Labeler](https://github.com/erdaltsksn/gh-label)
- [Golangci-lint](https://golangci-lint.run) - [Golangci-lint](https://golangci-lint.run)
- [GopherJS](http://www.gopherjs.org/) - [GopherJS](https://github.com/gopherjs/gopherjs)
- [GoReleaser](https://goreleaser.com) - [GoReleaser](https://goreleaser.com)
- [Helm](https://helm.sh) - [Helm](https://helm.sh)
- [Hugo](https://gohugo.io) - [Hugo](https://gohugo.io)
- [Infracost](https://github.com/infracost/infracost) - [Infracost](https://github.com/infracost/infracost)
- [Istio](https://istio.io) - [Istio](https://istio.io)
- [Kool](https://github.com/kool-dev/kool) - [Kool](https://github.com/kool-dev/kool)
- [Kubernetes](http://kubernetes.io/) - [Kubernetes](https://kubernetes.io/)
- [Kubescape](https://github.com/armosec/kubescape) - [Kubescape](https://github.com/armosec/kubescape)
- [Linkerd](https://linkerd.io/) - [Linkerd](https://linkerd.io/)
- [Mattermost-server](https://github.com/mattermost/mattermost-server) - [Mattermost-server](https://github.com/mattermost/mattermost-server)
@ -39,7 +39,7 @@
- [Pixie](https://github.com/pixie-io/pixie) - [Pixie](https://github.com/pixie-io/pixie)
- [Polygon Edge](https://github.com/0xPolygon/polygon-edge) - [Polygon Edge](https://github.com/0xPolygon/polygon-edge)
- [Pouch](https://github.com/alibaba/pouch) - [Pouch](https://github.com/alibaba/pouch)
- [ProjectAtomic (enterprise)](http://www.projectatomic.io/) - [ProjectAtomic (enterprise)](https://www.projectatomic.io/)
- [Prototool](https://github.com/uber/prototool) - [Prototool](https://github.com/uber/prototool)
- [QRcp](https://github.com/claudiodangelis/qrcp) - [QRcp](https://github.com/claudiodangelis/qrcp)
- [Random](https://github.com/erdaltsksn/random) - [Random](https://github.com/erdaltsksn/random)

View file

@ -51,7 +51,7 @@ var rootCmd = &cobra.Command{
Short: "Hugo is a very fast static site generator", Short: "Hugo is a very fast static site generator",
Long: `A Fast and Flexible Static Site Generator built with Long: `A Fast and Flexible Static Site Generator built with
love by spf13 and friends in Go. love by spf13 and friends in Go.
Complete documentation is available at http://hugo.spf13.com`, Complete documentation is available at https://gohugo.io/documentation/`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here // Do Stuff Here
}, },
@ -429,7 +429,7 @@ a count and a string.`,
} }
``` ```
For a more complete example of a larger application, please checkout [Hugo](http://gohugo.io/). For a more complete example of a larger application, please checkout [Hugo](https://gohugo.io/).
## Help Command ## Help Command
@ -627,7 +627,7 @@ Did you mean this?
Run 'hugo --help' for usage. Run 'hugo --help' for usage.
``` ```
Suggestions are automatic based on every subcommand registered and use an implementation of [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion. Suggestions are automatic based on every subcommand registered and use an implementation of [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion.
If you need to disable suggestions or tweak the string distance in your command, use: If you need to disable suggestions or tweak the string distance in your command, use: