
This removes indirect dependencies from go.mod, and includes the fix for the missing -help flag info. The latest cobra release is v1.2.1. Given that there were minor security-related dependency cleanup during v1.2 release, I was tempted to pick up the latest version, but that caused dependency updates in golang.org/x/sys and golang.org/x/tools which may be too recent (golang.org/x/* follow the go's release support policy, so recent versions may not be compatible with go versions beyond go's official version support policy). Verified that dlv still builds with go1.12.x. (go1.12 is the oldest version of go that can build the latest delve already). $ go get -d github.com/spf13/cobra@v1.1.3 $ go mod tidy $ go mod vendor $ go run _scripts/gen-usage-docs.go
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
// 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 command 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() }
|