From 5be159ba94297beab73f7cf38f41b72d693d89a1 Mon Sep 17 00:00:00 2001 From: Jrohy Date: Sun, 23 Feb 2020 15:22:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0trojan=20status=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/status.go | 35 +++++++++++++++++++++++++++++++++++ trojan/user.go | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 cmd/status.go diff --git a/cmd/status.go b/cmd/status.go new file mode 100644 index 00000000..88f22258 --- /dev/null +++ b/cmd/status.go @@ -0,0 +1,35 @@ +/* +Copyright © 2020 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "trojan/trojan" + + "github.com/spf13/cobra" +) + +// statusCmd represents the status command +var statusCmd = &cobra.Command{ + Use: "status", + Short: "查看trojan状态", + Run: func(cmd *cobra.Command, args []string) { + trojan.Status() + }, +} + +func init() { + rootCmd.AddCommand(statusCmd) +} diff --git a/trojan/user.go b/trojan/user.go index 6ed549ab..86570912 100644 --- a/trojan/user.go +++ b/trojan/user.go @@ -90,7 +90,7 @@ func UserList(ids ...string) *[]core.User { fmt.Println("上传流量: " + util.Cyan(util.Bytefmt(k.Upload))) fmt.Println("下载流量: " + util.Cyan(util.Bytefmt(k.Download))) if k.Quota < 0 { - fmt.Println(util.Cyan("流量限额: 无限制")) + fmt.Println("流量限额: " + util.Cyan("无限制")) } else { fmt.Println("流量限额: " + util.Cyan(util.Bytefmt(uint64(k.Quota)))) }