|
@@ -154,7 +154,7 @@ func (svr *Server) formatDescription(ss ...string) (usage string, description st
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func (svr *Server) Handle(path string, cb HandleFunc, args ...Option) {
|
|
|
+func (svr *Server) Handle(path string, cb HandleFunc, cbs ...Option) {
|
|
|
var (
|
|
|
err error
|
|
|
length int
|
|
@@ -169,9 +169,12 @@ func (svr *Server) Handle(path string, cb HandleFunc, args ...Option) {
|
|
|
tokens = utils.BreakUp(path)
|
|
|
}
|
|
|
opts := &Options{}
|
|
|
- for _, o := range args {
|
|
|
+ for _, o := range cbs {
|
|
|
o(opts)
|
|
|
}
|
|
|
+ if opts.Usage == "" && opts.Description == "" {
|
|
|
+ opts.Usage, opts.Description = svr.formatDescription(tokens...)
|
|
|
+ }
|
|
|
svr.locker.Lock()
|
|
|
defer svr.locker.Unlock()
|
|
|
length = len(tokens)
|
|
@@ -206,7 +209,7 @@ func (svr *Server) Handle(path string, cb HandleFunc, args ...Option) {
|
|
|
}
|
|
|
p = q
|
|
|
} else {
|
|
|
- q = NewExecutor(token, "", "")
|
|
|
+ q = NewExecutor(token)
|
|
|
if i == length-1 {
|
|
|
q.usage = opts.Usage
|
|
|
q.description = opts.Description
|