diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-20 15:46:14 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-20 15:46:14 +0200 |
commit | e89f87624f27b7b98efc959bd96e260ac86f9236 (patch) | |
tree | 6561a1c1eb1660736c48d668f43ccaf67cce19a2 /vendor/github.com/spf13/cobra/doc/util.go | |
parent | 1dd5118eebe0e993d55ae5433cb2dcfd2764bf4f (diff) | |
download | git-bug-e89f87624f27b7b98efc959bd96e260ac86f9236.tar.gz |
generate markdown documentation
Diffstat (limited to 'vendor/github.com/spf13/cobra/doc/util.go')
-rw-r--r-- | vendor/github.com/spf13/cobra/doc/util.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/github.com/spf13/cobra/doc/util.go b/vendor/github.com/spf13/cobra/doc/util.go new file mode 100644 index 00000000..8d3dbece --- /dev/null +++ b/vendor/github.com/spf13/cobra/doc/util.go @@ -0,0 +1,51 @@ +// Copyright 2015 Red Hat Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package doc + +import ( + "strings" + + "github.com/spf13/cobra" +) + +// Test to see if we have a reason to print See Also information in docs +// Basically this is a test for a parent commend or a subcommand which is +// both not deprecated and not the autogenerated help command. +func hasSeeAlso(cmd *cobra.Command) bool { + if cmd.HasParent() { + return true + } + for _, c := range cmd.Commands() { + if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { + continue + } + return true + } + return false +} + +// Temporary workaround for yaml lib generating incorrect yaml with long strings +// that do not contain \n. +func forceMultiLine(s string) string { + if len(s) > 60 && !strings.Contains(s, "\n") { + s = s + "\n" + } + return s +} + +type byName []*cobra.Command + +func (s byName) Len() int { return len(s) } +func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } |