Jelajahi Sumber

优化cli添加option方法

fancl 2 tahun lalu
induk
melakukan
0be5d9074b
1 mengubah file dengan 12 tambahan dan 0 penghapusan
  1. 12 0
      gateway/cli/server.go

+ 12 - 0
gateway/cli/server.go

@@ -41,6 +41,18 @@ type Server struct {
 	contextMap map[int32]*Context
 	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) {
 func (svr *Server) writePack(conn net.Conn, packet *Frame) (err error) {
 	if packet.Timestamp == 0 {
 	if packet.Timestamp == 0 {
 		packet.Timestamp = time.Now().Unix()
 		packet.Timestamp = time.Now().Unix()