Browse Source

优化cli添加option方法

fancl 2 years ago
parent
commit
0be5d9074b
1 changed files with 12 additions and 0 deletions
  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()