Skip to content

Commit

Permalink
v0.1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
vouv committed Nov 2, 2020
1 parent 8827752 commit e480a49
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
- 支持linux、maxOS、windows
- 基于Go语言实现

TODO: 使用gitee构建

## Update Log

2020.11.2
Expand Down Expand Up @@ -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.
```

Expand All @@ -106,24 +107,28 @@ $ srun config
>vouv
设置校园网密码:
>
INFO[2019-12-02 21:30:49] 账号密码已被保存
INFO[2020-11-02 21:30:49] 账号密码已被保存
```

### Login

```
$ 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
```


Expand Down Expand Up @@ -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)




Expand Down
2 changes: 1 addition & 1 deletion cmd/srun/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
)

const Version = "v0.1.25"
const Version = "v0.1.26"

var loginCmd = &cobra.Command{
Use: "login",
Expand Down
2 changes: 1 addition & 1 deletion model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
6 changes: 3 additions & 3 deletions utils/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e480a49

Please sign in to comment.