From e480a4925e03aa7172689b81c18797140851910a Mon Sep 17 00:00:00 2001 From: vouv Date: Mon, 2 Nov 2020 22:11:16 +0800 Subject: [PATCH] v0.1.26 --- README.md | 49 ++++++++++++++++++++++++++---------------------- cmd/srun/main.go | 2 +- model/model.go | 2 +- utils/format.go | 6 +++--- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 29d0894..08c39c7 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ - 支持linux、maxOS、windows - 基于Go语言实现 -TODO: 使用gitee构建 - ## Update Log 2020.11.2 @@ -79,22 +77,25 @@ Usage: `srun [OPTIONS] COMMAND` ``` $ srun -h -Usage: srun [OPTIONS] COMMAND - A efficient client for BIT campus network -Options: - -h Show help - -d Show debug message - -v Print version information and quit +Usage: + srun [command] [flags] + srun [command] + +Available Commands: + config config srun + help Help about any command + info get srun info + login login srun + logout logout srun -Commands: - login Login Srun - logout Logout Srun - info Get Srun Info - update Update srun - config Set Username and Password +Flags: + -d, --debug debug mode + -h, --help help for srun + -v, --version version for srun +Use "srun [command] --help" for more information about a command. ``` @@ -106,7 +107,7 @@ $ srun config >vouv 设置校园网密码: > -INFO[2019-12-02 21:30:49] 账号密码已被保存 +INFO[2020-11-02 21:30:49] 账号密码已被保存 ``` @@ -114,16 +115,20 @@ INFO[2019-12-02 21:30:49] 账号密码已被保存 ``` $ srun login -INFO[2019-12-02 21:31:17] 尝试登录 +INFO[2020-11-02 22:08:18] 尝试登录... +INFO[2020-11-02 22:08:18] 登录成功! ... ``` ### Extra - 查看余额 ``` $ srun info -已用流量: 54,418.87M -已用时长: 366小时38分48秒 -账户余额: ¥19.68 +用户名: vouv +IP地址: 10.51.92.21 +已用流量: 5.63GB +已用时长: 25时28分04秒 +账户余额: 11.40 + ``` @@ -167,11 +172,11 @@ $ make linux - 使用账号快速登录校园网,环境支持的情况下也可以一键登录 - ### Thanks to -- [beego](https://github.com/astaxie/beego) -- [goquery](https://github.com/PuerkitoBio/goquery) +- [logrus](https://github.com/sirupsen/logrus) +- [cobra](https://github.com/spf13/cobra) + diff --git a/cmd/srun/main.go b/cmd/srun/main.go index 4931cfa..85be60f 100755 --- a/cmd/srun/main.go +++ b/cmd/srun/main.go @@ -6,7 +6,7 @@ import ( "os" ) -const Version = "v0.1.25" +const Version = "v0.1.26" var loginCmd = &cobra.Command{ Use: "login", diff --git a/model/model.go b/model/model.go index 32db5ae..ff77c30 100644 --- a/model/model.go +++ b/model/model.go @@ -65,7 +65,7 @@ func (r *RInfo) String() string { sb.WriteString(fmt.Sprintf("IP地址: %s\n", r.OnlineIp)) sb.WriteString(fmt.Sprintf("已用流量: %s\n", utils.FormatFlux(r.SumBytes))) sb.WriteString(fmt.Sprintf("已用时长: %s\n", utils.FormatTime(r.SumSeconds))) - sb.WriteString(fmt.Sprintf("账户余额: %.2f\n", r.UserBalance)) + sb.WriteString(fmt.Sprintf("账户余额: ¥%.2f\n", r.UserBalance)) return sb.String() } diff --git a/utils/format.go b/utils/format.go index e080947..38146d2 100644 --- a/utils/format.go +++ b/utils/format.go @@ -10,13 +10,13 @@ func FormatFlux(byte int64) string { const mb = gb / 1024 const kb = 1024 if byte > tb { - return fmt.Sprintf("%dTB", byte/tb) + return fmt.Sprintf("%.2fTB", float64(byte)/tb) } if byte > gb { - return fmt.Sprintf("%dGB", byte/gb) + return fmt.Sprintf("%.2fGB", float64(byte)/gb) } if byte > mb { - return fmt.Sprintf("%dMB", byte/mb) + return fmt.Sprintf("%.1fMB", float64(byte)/mb) } if byte > kb { return fmt.Sprintf("%dKB", byte/kb)