Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
2b422b1a
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b422b1a
编写于
8月 11, 2017
作者:
M
Maximilian Meister
提交者:
Felix Lange
8月 11, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd/geth, cmd/swarm: sort commands and flags by name (#3462)
上级
73c5aba2
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
197 addition
and
56 deletion
+197
-56
cmd/geth/main.go
cmd/geth/main.go
+2
-0
cmd/swarm/main.go
cmd/swarm/main.go
+2
-0
vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md
vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md
+43
-0
vendor/gopkg.in/urfave/cli.v1/README.md
vendor/gopkg.in/urfave/cli.v1/README.md
+25
-8
vendor/gopkg.in/urfave/cli.v1/app.go
vendor/gopkg.in/urfave/cli.v1/app.go
+6
-1
vendor/gopkg.in/urfave/cli.v1/appveyor.yml
vendor/gopkg.in/urfave/cli.v1/appveyor.yml
+6
-4
vendor/gopkg.in/urfave/cli.v1/cli.go
vendor/gopkg.in/urfave/cli.v1/cli.go
+1
-0
vendor/gopkg.in/urfave/cli.v1/command.go
vendor/gopkg.in/urfave/cli.v1/command.go
+31
-13
vendor/gopkg.in/urfave/cli.v1/context.go
vendor/gopkg.in/urfave/cli.v1/context.go
+2
-0
vendor/gopkg.in/urfave/cli.v1/errors.go
vendor/gopkg.in/urfave/cli.v1/errors.go
+14
-9
vendor/gopkg.in/urfave/cli.v1/flag.go
vendor/gopkg.in/urfave/cli.v1/flag.go
+6
-6
vendor/gopkg.in/urfave/cli.v1/help.go
vendor/gopkg.in/urfave/cli.v1/help.go
+56
-12
vendor/vendor.json
vendor/vendor.json
+3
-3
未找到文件。
cmd/geth/main.go
浏览文件 @
2b422b1a
...
...
@@ -21,6 +21,7 @@ import (
"fmt"
"os"
"runtime"
"sort"
"strings"
"time"
...
...
@@ -165,6 +166,7 @@ func init() {
// See config.go
dumpConfigCommand
,
}
sort
.
Sort
(
cli
.
CommandsByName
(
app
.
Commands
))
app
.
Flags
=
append
(
app
.
Flags
,
nodeFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
rpcFlags
...
)
...
...
cmd/swarm/main.go
浏览文件 @
2b422b1a
...
...
@@ -25,6 +25,7 @@ import (
"os"
"os/signal"
"runtime"
"sort"
"strconv"
"strings"
"syscall"
...
...
@@ -302,6 +303,7 @@ DEPRECATED: use 'swarm db clean'.
`
,
},
}
sort
.
Sort
(
cli
.
CommandsByName
(
app
.
Commands
))
app
.
Flags
=
[]
cli
.
Flag
{
utils
.
IdentityFlag
,
...
...
vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md
浏览文件 @
2b422b1a
...
...
@@ -4,6 +4,49 @@
## [Unreleased]
## 1.20.0 - 2017-08-10
### Fixed
*
`HandleExitCoder`
is now correctly iterates over all errors in
a
`MultiError`
. The exit code is the exit code of the last error or
`1`
if
there are no
`ExitCoder`
s in the
`MultiError`
.
*
Fixed YAML file loading on Windows (previously would fail validate the file path)
*
Subcommand
`Usage`
,
`Description`
,
`ArgsUsage`
,
`OnUsageError`
correctly
propogated
*
`ErrWriter`
is now passed downwards through command structure to avoid the
need to redefine it
*
Pass
`Command`
context into
`OnUsageError`
rather than parent context so that
all fields are avaiable
*
Errors occuring in
`Before`
funcs are no longer double printed
*
Use
`UsageText`
in the help templates for commands and subcommands if
defined; otherwise build the usage as before (was previously ignoring this
field)
*
`IsSet`
and
`GlobalIsSet`
now correctly return whether a flag is set if
a program calls
`Set`
or
`GlobalSet`
directly after flag parsing (would
previously only return
`true`
if the flag was set during parsing)
### Changed
*
No longer exit the program on command/subcommand error if the error raised is
not an
`OsExiter`
. This exiting behavior was introduced in 1.19.0, but was
determined to be a regression in functionality. See
[
the
PR
](
https://github.com/urfave/cli/pull/595
)
for discussion.
### Added
*
`CommandsByName`
type was added to make it easy to sort
`Command`
s by name,
alphabetically
*
`altsrc`
now handles loading of string and int arrays from TOML
*
Support for definition of custom help templates for
`App`
via
`CustomAppHelpTemplate`
*
Support for arbitrary key/value fields on
`App`
to be used with
`CustomAppHelpTemplate`
via
`ExtraInfo`
*
`HelpFlag`
,
`VersionFlag`
, and
`BashCompletionFlag`
changed to explictly be
`cli.Flag`
s allowing for the use of custom flags satisfying the
`cli.Flag`
interface to be used.
## [1.19.1] - 2016-11-21
### Fixed
...
...
vendor/gopkg.in/urfave/cli.v1/README.md
浏览文件 @
2b422b1a
...
...
@@ -455,13 +455,13 @@ error.
Flags for the application and commands are shown in the order they are defined.
However, it's possible to sort them from outside this library by using
`FlagsByName`
with
`sort`
.
or
`CommandsByName`
with
`sort`
.
For example this:
<!-- {
"args": ["
--
help"],
"output": "Load configuration from FILE
\n
.
*Language for the greeting.*
"
"output": "
add a task to the list
\n
.
*complete a task on the list\n.*
\n\n
.
*\n.*
Load configuration from FILE
\n
.
*Language for the greeting.*
"
} -->
```
go
package
main
...
...
@@ -488,7 +488,27 @@ func main() {
},
}
app
.
Commands
=
[]
cli
.
Command
{
{
Name
:
"complete"
,
Aliases
:
[]
string
{
"c"
},
Usage
:
"complete a task on the list"
,
Action
:
func
(
c
*
cli
.
Context
)
error
{
return
nil
},
},
{
Name
:
"add"
,
Aliases
:
[]
string
{
"a"
},
Usage
:
"add a task to the list"
,
Action
:
func
(
c
*
cli
.
Context
)
error
{
return
nil
},
},
}
sort
.
Sort
(
cli
.
FlagsByName
(
app
.
Flags
))
sort
.
Sort
(
cli
.
CommandsByName
(
app
.
Commands
))
app
.
Run
(
os
.
Args
)
}
...
...
@@ -940,16 +960,13 @@ SUPPORT: support@awesometown.example.com
cli
.
AppHelpTemplate
=
`NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command
[command options]{{end}} {{if
.ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
{{if len .Authors}}
AUTHOR
(S)
:
AUTHOR:
{{range .Authors}}{{ . }}{{end}}
{{end}}{{if .Commands}}
COMMANDS:
{{range .Commands}}{{if not .HideHelp}} {{join .Names ", "}}{{ "\t"
}}{{.Usage}}{{ "\n" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
{{range .Commands}}{{if not .HideHelp}} {{join .Names ", "}}{{ "\t"}}{{.Usage}}{{ "\n" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
GLOBAL OPTIONS:
{{range .VisibleFlags}}{{.}}
{{end}}{{end}}{{if .Copyright }}
...
...
vendor/gopkg.in/urfave/cli.v1/app.go
浏览文件 @
2b422b1a
...
...
@@ -85,6 +85,12 @@ type App struct {
ErrWriter
io
.
Writer
// Other custom info
Metadata
map
[
string
]
interface
{}
// Carries a function which returns app specific info.
ExtraInfo
func
()
map
[
string
]
string
// CustomAppHelpTemplate the text template for app help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
CustomAppHelpTemplate
string
didSetup
bool
}
...
...
@@ -234,7 +240,6 @@ func (a *App) Run(arguments []string) (err error) {
if
a
.
Before
!=
nil
{
beforeErr
:=
a
.
Before
(
context
)
if
beforeErr
!=
nil
{
fmt
.
Fprintf
(
a
.
Writer
,
"%v
\n\n
"
,
beforeErr
)
ShowAppHelp
(
context
)
HandleExitCoder
(
beforeErr
)
err
=
beforeErr
...
...
vendor/gopkg.in/urfave/cli.v1/appveyor.yml
浏览文件 @
2b422b1a
version
:
"
{build}"
os
:
Windows Server 2012 R2
os
:
Windows Server
2016
image
:
Visual Studio
2017
clone_folder
:
c:\gopath\src\github.com\urfave\cli
environment
:
GOPATH
:
C:\gopath
GOVERSION
:
1.
6
PYTHON
:
C:\Python
27
-x64
PYTHON_VERSION
:
2.7
.x
GOVERSION
:
1.
8.x
PYTHON
:
C:\Python
36
-x64
PYTHON_VERSION
:
3.6
.x
PYTHON_ARCH
:
64
install
:
...
...
vendor/gopkg.in/urfave/cli.v1/cli.go
浏览文件 @
2b422b1a
...
...
@@ -12,6 +12,7 @@
// app.Usage = "say a greeting"
// app.Action = func(c *cli.Context) error {
// println("Greetings")
// return nil
// }
//
// app.Run(os.Args)
...
...
vendor/gopkg.in/urfave/cli.v1/command.go
浏览文件 @
2b422b1a
...
...
@@ -59,6 +59,25 @@ type Command struct {
// Full name of command for help, defaults to full command name, including parent commands.
HelpName
string
commandNamePath
[]
string
// CustomHelpTemplate the text template for the command help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
CustomHelpTemplate
string
}
type
CommandsByName
[]
Command
func
(
c
CommandsByName
)
Len
()
int
{
return
len
(
c
)
}
func
(
c
CommandsByName
)
Less
(
i
,
j
int
)
bool
{
return
c
[
i
]
.
Name
<
c
[
j
]
.
Name
}
func
(
c
CommandsByName
)
Swap
(
i
,
j
int
)
{
c
[
i
],
c
[
j
]
=
c
[
j
],
c
[
i
]
}
// FullName returns the full name of the command.
...
...
@@ -140,19 +159,20 @@ func (c Command) Run(ctx *Context) (err error) {
}
context
:=
NewContext
(
ctx
.
App
,
set
,
ctx
)
context
.
Command
=
c
if
checkCommandCompletions
(
context
,
c
.
Name
)
{
return
nil
}
if
err
!=
nil
{
if
c
.
OnUsageError
!=
nil
{
err
:=
c
.
OnUsageError
(
c
tx
,
err
,
false
)
err
:=
c
.
OnUsageError
(
c
ontext
,
err
,
false
)
HandleExitCoder
(
err
)
return
err
}
fmt
.
Fprintln
(
c
tx
.
App
.
Writer
,
"Incorrect Usage:"
,
err
.
Error
())
fmt
.
Fprintln
(
c
tx
.
App
.
Writer
)
ShowCommandHelp
(
c
tx
,
c
.
Name
)
fmt
.
Fprintln
(
c
ontext
.
App
.
Writer
,
"Incorrect Usage:"
,
err
.
Error
())
fmt
.
Fprintln
(
c
ontext
.
App
.
Writer
)
ShowCommandHelp
(
c
ontext
,
c
.
Name
)
return
err
}
...
...
@@ -177,9 +197,7 @@ func (c Command) Run(ctx *Context) (err error) {
if
c
.
Before
!=
nil
{
err
=
c
.
Before
(
context
)
if
err
!=
nil
{
fmt
.
Fprintln
(
ctx
.
App
.
Writer
,
err
)
fmt
.
Fprintln
(
ctx
.
App
.
Writer
)
ShowCommandHelp
(
ctx
,
c
.
Name
)
ShowCommandHelp
(
context
,
c
.
Name
)
HandleExitCoder
(
err
)
return
err
}
...
...
@@ -189,7 +207,6 @@ func (c Command) Run(ctx *Context) (err error) {
c
.
Action
=
helpSubcommand
.
Action
}
context
.
Command
=
c
err
=
HandleAction
(
c
.
Action
,
context
)
if
err
!=
nil
{
...
...
@@ -230,14 +247,13 @@ func (c Command) startApp(ctx *Context) error {
app
.
HelpName
=
app
.
Name
}
if
c
.
Description
!=
""
{
app
.
Usage
=
c
.
Description
}
else
{
app
.
Usage
=
c
.
Usage
}
app
.
Usage
=
c
.
Usage
app
.
Description
=
c
.
Description
app
.
ArgsUsage
=
c
.
ArgsUsage
// set CommandNotFound
app
.
CommandNotFound
=
ctx
.
App
.
CommandNotFound
app
.
CustomAppHelpTemplate
=
c
.
CustomHelpTemplate
// set the flags and commands
app
.
Commands
=
c
.
Subcommands
...
...
@@ -250,6 +266,7 @@ func (c Command) startApp(ctx *Context) error {
app
.
Author
=
ctx
.
App
.
Author
app
.
Email
=
ctx
.
App
.
Email
app
.
Writer
=
ctx
.
App
.
Writer
app
.
ErrWriter
=
ctx
.
App
.
ErrWriter
app
.
categories
=
CommandCategories
{}
for
_
,
command
:=
range
c
.
Subcommands
{
...
...
@@ -272,6 +289,7 @@ func (c Command) startApp(ctx *Context) error {
}
else
{
app
.
Action
=
helpSubcommand
.
Action
}
app
.
OnUsageError
=
c
.
OnUsageError
for
index
,
cc
:=
range
app
.
Commands
{
app
.
Commands
[
index
]
.
commandNamePath
=
[]
string
{
c
.
Name
,
cc
.
Name
}
...
...
vendor/gopkg.in/urfave/cli.v1/context.go
浏览文件 @
2b422b1a
...
...
@@ -39,11 +39,13 @@ func (c *Context) NumFlags() int {
// Set sets a context flag to a value.
func
(
c
*
Context
)
Set
(
name
,
value
string
)
error
{
c
.
setFlags
=
nil
return
c
.
flagSet
.
Set
(
name
,
value
)
}
// GlobalSet sets a context flag to a value on the global flagset
func
(
c
*
Context
)
GlobalSet
(
name
,
value
string
)
error
{
globalContext
(
c
)
.
setFlags
=
nil
return
globalContext
(
c
)
.
flagSet
.
Set
(
name
,
value
)
}
...
...
vendor/gopkg.in/urfave/cli.v1/errors.go
浏览文件 @
2b422b1a
...
...
@@ -74,7 +74,7 @@ func (ee *ExitError) ExitCode() int {
// HandleExitCoder checks if the error fulfills the ExitCoder interface, and if
// so prints the error to stderr (if it is non-empty) and calls OsExiter with the
// given exit code. If the given error is a MultiError, then this func is
// called on all members of the Errors slice.
// called on all members of the Errors slice
and calls OsExiter with the last exit code
.
func
HandleExitCoder
(
err
error
)
{
if
err
==
nil
{
return
...
...
@@ -93,18 +93,23 @@ func HandleExitCoder(err error) {
}
if
multiErr
,
ok
:=
err
.
(
MultiError
);
ok
{
for
_
,
merr
:=
range
multiErr
.
Errors
{
HandleExitCoder
(
merr
)
}
code
:=
handleMultiError
(
multiErr
)
OsExiter
(
code
)
return
}
}
if
err
.
Error
()
!=
""
{
if
_
,
ok
:=
err
.
(
ErrorFormatter
);
ok
{
fmt
.
Fprintf
(
ErrWriter
,
"%+v
\n
"
,
err
)
func
handleMultiError
(
multiErr
MultiError
)
int
{
code
:=
1
for
_
,
merr
:=
range
multiErr
.
Errors
{
if
multiErr2
,
ok
:=
merr
.
(
MultiError
);
ok
{
code
=
handleMultiError
(
multiErr2
)
}
else
{
fmt
.
Fprintln
(
ErrWriter
,
err
)
fmt
.
Fprintln
(
ErrWriter
,
merr
)
if
exitErr
,
ok
:=
merr
.
(
ExitCoder
);
ok
{
code
=
exitErr
.
ExitCode
()
}
}
}
OsExiter
(
1
)
return
code
}
vendor/gopkg.in/urfave/cli.v1/flag.go
浏览文件 @
2b422b1a
...
...
@@ -14,13 +14,13 @@ import (
const
defaultPlaceholder
=
"value"
// BashCompletionFlag enables bash-completion for all commands and subcommands
var
BashCompletionFlag
=
BoolFlag
{
var
BashCompletionFlag
Flag
=
BoolFlag
{
Name
:
"generate-bash-completion"
,
Hidden
:
true
,
}
// VersionFlag prints the version for the application
var
VersionFlag
=
BoolFlag
{
var
VersionFlag
Flag
=
BoolFlag
{
Name
:
"version, v"
,
Usage
:
"print the version"
,
}
...
...
@@ -28,7 +28,7 @@ var VersionFlag = BoolFlag{
// HelpFlag prints the help for all commands and subcommands
// Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand
// unless HideHelp is set to true)
var
HelpFlag
=
BoolFlag
{
var
HelpFlag
Flag
=
BoolFlag
{
Name
:
"help, h"
,
Usage
:
"show help"
,
}
...
...
@@ -630,7 +630,8 @@ func (f Float64Flag) ApplyWithError(set *flag.FlagSet) error {
func
visibleFlags
(
fl
[]
Flag
)
[]
Flag
{
visible
:=
[]
Flag
{}
for
_
,
flag
:=
range
fl
{
if
!
flagValue
(
flag
)
.
FieldByName
(
"Hidden"
)
.
Bool
()
{
field
:=
flagValue
(
flag
)
.
FieldByName
(
"Hidden"
)
if
!
field
.
IsValid
()
||
!
field
.
Bool
()
{
visible
=
append
(
visible
,
flag
)
}
}
...
...
@@ -723,9 +724,8 @@ func stringifyFlag(f Flag) string {
needsPlaceholder
:=
false
defaultValueString
:=
""
val
:=
fv
.
FieldByName
(
"Value"
)
if
val
.
IsValid
()
{
if
val
:=
fv
.
FieldByName
(
"Value"
);
val
.
IsValid
()
{
needsPlaceholder
=
true
defaultValueString
=
fmt
.
Sprintf
(
" (default: %v)"
,
val
.
Interface
())
...
...
vendor/gopkg.in/urfave/cli.v1/help.go
浏览文件 @
2b422b1a
...
...
@@ -47,7 +47,7 @@ var CommandHelpTemplate = `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{
.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]
{{end}}{{if .Category}}
{{
if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
{{end}}{{if .Category}}
CATEGORY:
{{.Category}}{{end}}{{if .Description}}
...
...
@@ -64,10 +64,10 @@ OPTIONS:
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var
SubcommandHelpTemplate
=
`NAME:
{{.HelpName}} - {{
.Usage
}}
{{.HelpName}} - {{
if .Description}}{{.Description}}{{else}}{{.Usage}}{{end
}}
USAGE:
{{
.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]
{{end}}
{{
if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
{{end}}
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{end}}{{range .VisibleCommands}}
...
...
@@ -112,17 +112,42 @@ var helpSubcommand = Command{
// Prints help for the App or Command
type
helpPrinter
func
(
w
io
.
Writer
,
templ
string
,
data
interface
{})
// Prints help for the App or Command with custom template function.
type
helpPrinterCustom
func
(
w
io
.
Writer
,
templ
string
,
data
interface
{},
customFunc
map
[
string
]
interface
{})
// HelpPrinter is a function that writes the help output. If not set a default
// is used. The function signature is:
// func(w io.Writer, templ string, data interface{})
var
HelpPrinter
helpPrinter
=
printHelp
// HelpPrinterCustom is same as HelpPrinter but
// takes a custom function for template function map.
var
HelpPrinterCustom
helpPrinterCustom
=
printHelpCustom
// VersionPrinter prints the version for the App
var
VersionPrinter
=
printVersion
// ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code.
func
ShowAppHelpAndExit
(
c
*
Context
,
exitCode
int
)
{
ShowAppHelp
(
c
)
os
.
Exit
(
exitCode
)
}
// ShowAppHelp is an action that displays the help.
func
ShowAppHelp
(
c
*
Context
)
error
{
HelpPrinter
(
c
.
App
.
Writer
,
AppHelpTemplate
,
c
.
App
)
func
ShowAppHelp
(
c
*
Context
)
(
err
error
)
{
if
c
.
App
.
CustomAppHelpTemplate
==
""
{
HelpPrinter
(
c
.
App
.
Writer
,
AppHelpTemplate
,
c
.
App
)
return
}
customAppData
:=
func
()
map
[
string
]
interface
{}
{
if
c
.
App
.
ExtraInfo
==
nil
{
return
nil
}
return
map
[
string
]
interface
{}{
"ExtraInfo"
:
c
.
App
.
ExtraInfo
,
}
}
HelpPrinterCustom
(
c
.
App
.
Writer
,
c
.
App
.
CustomAppHelpTemplate
,
c
.
App
,
customAppData
())
return
nil
}
...
...
@@ -138,6 +163,12 @@ func DefaultAppComplete(c *Context) {
}
}
// ShowCommandHelpAndExit - exits with code after showing help
func
ShowCommandHelpAndExit
(
c
*
Context
,
command
string
,
code
int
)
{
ShowCommandHelp
(
c
,
command
)
os
.
Exit
(
code
)
}
// ShowCommandHelp prints help for the given command
func
ShowCommandHelp
(
ctx
*
Context
,
command
string
)
error
{
// show the subcommand help for a command with subcommands
...
...
@@ -148,7 +179,11 @@ func ShowCommandHelp(ctx *Context, command string) error {
for
_
,
c
:=
range
ctx
.
App
.
Commands
{
if
c
.
HasName
(
command
)
{
HelpPrinter
(
ctx
.
App
.
Writer
,
CommandHelpTemplate
,
c
)
if
c
.
CustomHelpTemplate
!=
""
{
HelpPrinterCustom
(
ctx
.
App
.
Writer
,
c
.
CustomHelpTemplate
,
c
,
nil
)
}
else
{
HelpPrinter
(
ctx
.
App
.
Writer
,
CommandHelpTemplate
,
c
)
}
return
nil
}
}
...
...
@@ -191,10 +226,15 @@ func ShowCommandCompletions(ctx *Context, command string) {
}
}
func
printHelp
(
out
io
.
Writer
,
templ
string
,
data
interface
{})
{
func
printHelp
Custom
(
out
io
.
Writer
,
templ
string
,
data
interface
{},
customFunc
map
[
string
]
interface
{})
{
funcMap
:=
template
.
FuncMap
{
"join"
:
strings
.
Join
,
}
if
customFunc
!=
nil
{
for
key
,
value
:=
range
customFunc
{
funcMap
[
key
]
=
value
}
}
w
:=
tabwriter
.
NewWriter
(
out
,
1
,
8
,
2
,
' '
,
0
)
t
:=
template
.
Must
(
template
.
New
(
"help"
)
.
Funcs
(
funcMap
)
.
Parse
(
templ
))
...
...
@@ -210,10 +250,14 @@ func printHelp(out io.Writer, templ string, data interface{}) {
w
.
Flush
()
}
func
printHelp
(
out
io
.
Writer
,
templ
string
,
data
interface
{})
{
printHelpCustom
(
out
,
templ
,
data
,
nil
)
}
func
checkVersion
(
c
*
Context
)
bool
{
found
:=
false
if
VersionFlag
.
Name
!=
""
{
eachName
(
VersionFlag
.
Name
,
func
(
name
string
)
{
if
VersionFlag
.
GetName
()
!=
""
{
eachName
(
VersionFlag
.
GetName
()
,
func
(
name
string
)
{
if
c
.
GlobalBool
(
name
)
||
c
.
Bool
(
name
)
{
found
=
true
}
...
...
@@ -224,8 +268,8 @@ func checkVersion(c *Context) bool {
func
checkHelp
(
c
*
Context
)
bool
{
found
:=
false
if
HelpFlag
.
Name
!=
""
{
eachName
(
HelpFlag
.
Name
,
func
(
name
string
)
{
if
HelpFlag
.
GetName
()
!=
""
{
eachName
(
HelpFlag
.
GetName
()
,
func
(
name
string
)
{
if
c
.
GlobalBool
(
name
)
||
c
.
Bool
(
name
)
{
found
=
true
}
...
...
@@ -260,7 +304,7 @@ func checkShellCompleteFlag(a *App, arguments []string) (bool, []string) {
pos
:=
len
(
arguments
)
-
1
lastArg
:=
arguments
[
pos
]
if
lastArg
!=
"--"
+
BashCompletionFlag
.
Name
{
if
lastArg
!=
"--"
+
BashCompletionFlag
.
GetName
()
{
return
false
,
arguments
}
...
...
vendor/vendor.json
浏览文件 @
2b422b1a
...
...
@@ -658,10 +658,10 @@
"revisionTime"
:
"2017-02-13T14:20:43Z"
},
{
"checksumSHA1"
:
"
brhONOPp4CSdTZf5uEtcH+FpFUI
="
,
"checksumSHA1"
:
"
Yx1MU40fyGe7hhqW9+dkv8kXa60
="
,
"path"
:
"gopkg.in/urfave/cli.v1"
,
"revision"
:
"
0bdeddeeb0f650497d603c4ad7b20cfe685682f6
"
,
"revisionTime"
:
"201
6-11-22T04:36:10
Z"
"revision"
:
"
cfb38830724cc34fedffe9a2a29fb54fa9169cd1
"
,
"revisionTime"
:
"201
7-08-11T01:42:03
Z"
}
],
"rootPath"
:
"github.com/ethereum/go-ethereum"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录