Selaa lähdekoodia

优化cli添加option方法

fancl 2 vuotta sitten
vanhempi
commit
0be5d9074b
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. 12 0
      gateway/cli/server.go

+ 12 - 0
gateway/cli/server.go

@@ -41,6 +41,18 @@ type Server struct {
 	contextMap map[int32]*Context
 }
 
+func WithUsage(usage string) Option {
+	return func(o *Options) {
+		o.Usage = usage
+	}
+}
+
+func WithDescription(desc string) Option {
+	return func(o *Options) {
+		o.Description = desc
+	}
+}
+
 func (svr *Server) writePack(conn net.Conn, packet *Frame) (err error) {
 	if packet.Timestamp == 0 {
 		packet.Timestamp = time.Now().Unix()