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)))) }