forked from forgejo/forgejo
[Vendor] Update directly used dependencys (#15593)
* update github.com/blevesearch/bleve v2.0.2 -> v2.0.3 * github.com/denisenkom/go-mssqldb v0.9.0 -> v0.10.0 * github.com/editorconfig/editorconfig-core-go v2.4.1 -> v2.4.2 * github.com/go-chi/cors v1.1.1 -> v1.2.0 * github.com/go-git/go-billy v5.0.0 -> v5.1.0 * github.com/go-git/go-git v5.2.0 -> v5.3.0 * github.com/go-ldap/ldap v3.2.4 -> v3.3.0 * github.com/go-redis/redis v8.6.0 -> v8.8.2 * github.com/go-sql-driver/mysql v1.5.0 -> v1.6.0 * github.com/go-swagger/go-swagger v0.26.1 -> v0.27.0 * github.com/lib/pq v1.9.0 -> v1.10.1 * github.com/mattn/go-sqlite3 v1.14.6 -> v1.14.7 * github.com/go-testfixtures/testfixtures v3.5.0 -> v3.6.0 * github.com/issue9/identicon v1.0.1 -> v1.2.0 * github.com/klauspost/compress v1.11.8 -> v1.12.1 * github.com/mgechev/revive v1.0.3 -> v1.0.6 * github.com/microcosm-cc/bluemonday v1.0.7 -> v1.0.8 * github.com/niklasfasching/go-org v1.4.0 -> v1.5.0 * github.com/olivere/elastic v7.0.22 -> v7.0.24 * github.com/pelletier/go-toml v1.8.1 -> v1.9.0 * github.com/prometheus/client_golang v1.9.0 -> v1.10.0 * github.com/xanzy/go-gitlab v0.44.0 -> v0.48.0 * github.com/yuin/goldmark v1.3.3 -> v1.3.5 * github.com/6543/go-version v1.2.4 -> v1.3.1 * do github.com/lib/pq v1.10.0 -> v1.10.1 again ...
This commit is contained in:
parent
834fc74873
commit
792b4dba2c
558 changed files with 32080 additions and 24669 deletions
76
vendor/github.com/jessevdk/go-flags/man.go
generated
vendored
76
vendor/github.com/jessevdk/go-flags/man.go
generated
vendored
|
@ -3,42 +3,55 @@ package flags
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func manQuoteLines(s string) string {
|
||||
lines := strings.Split(s, "\n")
|
||||
parts := []string{}
|
||||
|
||||
for _, line := range lines {
|
||||
parts = append(parts, manQuote(line))
|
||||
}
|
||||
|
||||
return strings.Join(parts, "\n")
|
||||
}
|
||||
|
||||
func manQuote(s string) string {
|
||||
return strings.Replace(s, "\\", "\\\\", -1)
|
||||
}
|
||||
|
||||
func formatForMan(wr io.Writer, s string) {
|
||||
func formatForMan(wr io.Writer, s string, quoter func(s string) string) {
|
||||
for {
|
||||
idx := strings.IndexRune(s, '`')
|
||||
|
||||
if idx < 0 {
|
||||
fmt.Fprintf(wr, "%s", manQuote(s))
|
||||
fmt.Fprintf(wr, "%s", quoter(s))
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Fprintf(wr, "%s", manQuote(s[:idx]))
|
||||
fmt.Fprintf(wr, "%s", quoter(s[:idx]))
|
||||
|
||||
s = s[idx+1:]
|
||||
idx = strings.IndexRune(s, '\'')
|
||||
|
||||
if idx < 0 {
|
||||
fmt.Fprintf(wr, "%s", manQuote(s))
|
||||
fmt.Fprintf(wr, "%s", quoter(s))
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Fprintf(wr, "\\fB%s\\fP", manQuote(s[:idx]))
|
||||
fmt.Fprintf(wr, "\\fB%s\\fP", quoter(s[:idx]))
|
||||
s = s[idx+1:]
|
||||
}
|
||||
}
|
||||
|
||||
func writeManPageOptions(wr io.Writer, grp *Group) {
|
||||
grp.eachGroup(func(group *Group) {
|
||||
if group.Hidden || len(group.options) == 0 {
|
||||
if !group.showInHelp() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -48,13 +61,13 @@ func writeManPageOptions(wr io.Writer, grp *Group) {
|
|||
fmt.Fprintf(wr, ".SS %s\n", group.ShortDescription)
|
||||
|
||||
if group.LongDescription != "" {
|
||||
formatForMan(wr, group.LongDescription)
|
||||
formatForMan(wr, group.LongDescription, manQuoteLines)
|
||||
fmt.Fprintln(wr, "")
|
||||
}
|
||||
}
|
||||
|
||||
for _, opt := range group.options {
|
||||
if !opt.canCli() || opt.Hidden {
|
||||
if !opt.showInHelp() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -83,11 +96,11 @@ func writeManPageOptions(wr io.Writer, grp *Group) {
|
|||
|
||||
if len(opt.Default) != 0 {
|
||||
fmt.Fprintf(wr, " <default: \\fI%s\\fR>", manQuote(strings.Join(quoteV(opt.Default), ", ")))
|
||||
} else if len(opt.EnvDefaultKey) != 0 {
|
||||
} else if len(opt.EnvKeyWithNamespace()) != 0 {
|
||||
if runtime.GOOS == "windows" {
|
||||
fmt.Fprintf(wr, " <default: \\fI%%%s%%\\fR>", manQuote(opt.EnvDefaultKey))
|
||||
fmt.Fprintf(wr, " <default: \\fI%%%s%%\\fR>", manQuote(opt.EnvKeyWithNamespace()))
|
||||
} else {
|
||||
fmt.Fprintf(wr, " <default: \\fI$%s\\fR>", manQuote(opt.EnvDefaultKey))
|
||||
fmt.Fprintf(wr, " <default: \\fI$%s\\fR>", manQuote(opt.EnvKeyWithNamespace()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,14 +111,14 @@ func writeManPageOptions(wr io.Writer, grp *Group) {
|
|||
fmt.Fprintln(wr, "\\fP")
|
||||
|
||||
if len(opt.Description) != 0 {
|
||||
formatForMan(wr, opt.Description)
|
||||
formatForMan(wr, opt.Description, manQuoteLines)
|
||||
fmt.Fprintln(wr, "")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func writeManPageSubcommands(wr io.Writer, name string, root *Command) {
|
||||
func writeManPageSubcommands(wr io.Writer, name string, usagePrefix string, root *Command) {
|
||||
commands := root.sortedVisibleCommands()
|
||||
|
||||
for _, c := range commands {
|
||||
|
@ -121,11 +134,11 @@ func writeManPageSubcommands(wr io.Writer, name string, root *Command) {
|
|||
nn = c.Name
|
||||
}
|
||||
|
||||
writeManPageCommand(wr, nn, root, c)
|
||||
writeManPageCommand(wr, nn, usagePrefix, c)
|
||||
}
|
||||
}
|
||||
|
||||
func writeManPageCommand(wr io.Writer, name string, root *Command, command *Command) {
|
||||
func writeManPageCommand(wr io.Writer, name string, usagePrefix string, command *Command) {
|
||||
fmt.Fprintf(wr, ".SS %s\n", name)
|
||||
fmt.Fprintln(wr, command.ShortDescription)
|
||||
|
||||
|
@ -137,30 +150,27 @@ func writeManPageCommand(wr io.Writer, name string, root *Command, command *Comm
|
|||
if strings.HasPrefix(command.LongDescription, cmdstart) {
|
||||
fmt.Fprintf(wr, "The \\fI%s\\fP command", manQuote(command.Name))
|
||||
|
||||
formatForMan(wr, command.LongDescription[len(cmdstart):])
|
||||
formatForMan(wr, command.LongDescription[len(cmdstart):], manQuoteLines)
|
||||
fmt.Fprintln(wr, "")
|
||||
} else {
|
||||
formatForMan(wr, command.LongDescription)
|
||||
formatForMan(wr, command.LongDescription, manQuoteLines)
|
||||
fmt.Fprintln(wr, "")
|
||||
}
|
||||
}
|
||||
|
||||
var pre = usagePrefix + " " + command.Name
|
||||
|
||||
var usage string
|
||||
if us, ok := command.data.(Usage); ok {
|
||||
usage = us.Usage()
|
||||
} else if command.hasCliOptions() {
|
||||
} else if command.hasHelpOptions() {
|
||||
usage = fmt.Sprintf("[%s-OPTIONS]", command.Name)
|
||||
}
|
||||
|
||||
var pre string
|
||||
if root.hasCliOptions() {
|
||||
pre = fmt.Sprintf("%s [OPTIONS] %s", root.Name, command.Name)
|
||||
} else {
|
||||
pre = fmt.Sprintf("%s %s", root.Name, command.Name)
|
||||
}
|
||||
|
||||
var nextPrefix = pre
|
||||
if len(usage) > 0 {
|
||||
fmt.Fprintf(wr, "\n\\fBUsage\\fP: %s %s\n.TP\n", manQuote(pre), manQuote(usage))
|
||||
nextPrefix = pre + " " + usage
|
||||
}
|
||||
|
||||
if len(command.Aliases) > 0 {
|
||||
|
@ -168,17 +178,25 @@ func writeManPageCommand(wr io.Writer, name string, root *Command, command *Comm
|
|||
}
|
||||
|
||||
writeManPageOptions(wr, command.Group)
|
||||
writeManPageSubcommands(wr, name, command)
|
||||
writeManPageSubcommands(wr, name, nextPrefix, command)
|
||||
}
|
||||
|
||||
// WriteManPage writes a basic man page in groff format to the specified
|
||||
// writer.
|
||||
func (p *Parser) WriteManPage(wr io.Writer) {
|
||||
t := time.Now()
|
||||
source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH")
|
||||
if source_date_epoch != "" {
|
||||
sde, err := strconv.ParseInt(source_date_epoch, 10, 64)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err))
|
||||
}
|
||||
t = time.Unix(sde, 0)
|
||||
}
|
||||
|
||||
fmt.Fprintf(wr, ".TH %s 1 \"%s\"\n", manQuote(p.Name), t.Format("2 January 2006"))
|
||||
fmt.Fprintln(wr, ".SH NAME")
|
||||
fmt.Fprintf(wr, "%s \\- %s\n", manQuote(p.Name), manQuote(p.ShortDescription))
|
||||
fmt.Fprintf(wr, "%s \\- %s\n", manQuote(p.Name), manQuoteLines(p.ShortDescription))
|
||||
fmt.Fprintln(wr, ".SH SYNOPSIS")
|
||||
|
||||
usage := p.Usage
|
||||
|
@ -190,7 +208,7 @@ func (p *Parser) WriteManPage(wr io.Writer) {
|
|||
fmt.Fprintf(wr, "\\fB%s\\fP %s\n", manQuote(p.Name), manQuote(usage))
|
||||
fmt.Fprintln(wr, ".SH DESCRIPTION")
|
||||
|
||||
formatForMan(wr, p.LongDescription)
|
||||
formatForMan(wr, p.LongDescription, manQuoteLines)
|
||||
fmt.Fprintln(wr, "")
|
||||
|
||||
fmt.Fprintln(wr, ".SH OPTIONS")
|
||||
|
@ -200,6 +218,6 @@ func (p *Parser) WriteManPage(wr io.Writer) {
|
|||
if len(p.visibleCommands()) > 0 {
|
||||
fmt.Fprintln(wr, ".SH COMMANDS")
|
||||
|
||||
writeManPageSubcommands(wr, "", p.Command)
|
||||
writeManPageSubcommands(wr, "", p.Name+" "+usage, p.Command)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue