util.go
This file
Path
doc/util.go
52 lines · 1.5 KiB · Go
Last changed by
More linting (#2099)Ville Skyttäbefore adoption6b5f577
History of this fileTake it
The walk stopped after 200 commits: lines older than 89d7b83 point at it.
update copyright year (#1927)Unai Martinez-Corralbefore adoption9e6b58a
line 1why, one step back1// Copyright 2013-2023 The Cobra AuthorsAdd Polygon Edge as a project using Cobra (#1672)Miloš Živkovićbefore adoption89d7b83
lines 2–5why, one step back2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License atadd missing license headers (#1809)Unai Martinez-Corralbefore adoption6d978a9
lines 6–7why, one step back6//7// http://www.apache.org/licenses/LICENSE-2.0Add Polygon Edge as a project using Cobra (#1672)Miloš Živkovićbefore adoption89d7b83
lines 8–42why, one step back8//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.1415package doc1617import (18 "strings"1920 "github.com/spf13/cobra"21)2223// Test to see if we have a reason to print See Also information in docs24// Basically this is a test for a parent command or a subcommand which is25// both not deprecated and not the autogenerated help command.26func hasSeeAlso(cmd *cobra.Command) bool {27 if cmd.HasParent() {28 return true29 }30 for _, c := range cmd.Commands() {31 if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() {32 continue33 }34 return true35 }36 return false37}3839// Temporary workaround for yaml lib generating incorrect yaml with long strings40// that do not contain \n.41func forceMultiLine(s string) string {42 if len(s) > 60 && !strings.Contains(s, "\n") {More linting (#2099)Ville Skyttäbefore adoption6b5f577
line 43why, one step back43 s += "\n"Add Polygon Edge as a project using Cobra (#1672)Miloš Živkovićbefore adoption89d7b83
lines 44–52why, one step back44 }45 return s46}4748type byName []*cobra.Command4950func (s byName) Len() int { return len(s) }51func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }52func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() }