From 264696c28a3c31d7e687e66d344a56f45946540d Mon Sep 17 00:00:00 2001 From: ZenithalHourlyRate Date: Fri, 16 Oct 2020 18:30:01 +0800 Subject: [PATCH 1/2] Add persistent option in config file for campus-only --- README.md | 3 ++- cli/main.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57e91d0..43f8e85 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,8 @@ The default location of config file is `~/.auth-thu`. "noCheck": false, "insecure": false, "daemonize": false, - "acId": "" + "acId": "", + "campusOnly": false } ``` diff --git a/cli/main.go b/cli/main.go index fee1647..2bbb98e 100644 --- a/cli/main.go +++ b/cli/main.go @@ -35,6 +35,7 @@ type Settings struct { Daemon bool `json:"daemonize"` Debug bool `json:"debug"` AcID string `json:"acId"` + Campus bool `json:"campusOnly"` } var logger = loggo.GetLogger("auth-thu") @@ -91,6 +92,7 @@ func mergeCliSettings(c *cli.Context) error { if len(merged.AcID) == 0 { merged.AcID = settings.AcID } + merged.Campus = settings.Campus || c.Bool("campus-only") settings = merged logger.Debugf("Settings Username: \"%s\"\n", settings.Username) logger.Debugf("Settings Ip: \"%s\"\n", settings.Ip) @@ -103,6 +105,7 @@ func mergeCliSettings(c *cli.Context) error { logger.Debugf("Settings Daemon: %t\n", settings.Daemon) logger.Debugf("Settings Debug: %t\n", settings.Debug) logger.Debugf("Settings AcID: \"%s\"\n", settings.AcID) + logger.Debugf("Settings Campus: %t\n", settings.Campus) return nil } @@ -312,7 +315,7 @@ func cmdAuthUtil(c *cli.Context, logout bool) error { } } - if c.Bool("campus-only") { + if settings.Campus { settings.Username += "@tsinghua" } From f75be708e7fdaddec53f156f6670098876d132dd Mon Sep 17 00:00:00 2001 From: ZenithalHourlyRate Date: Fri, 16 Oct 2020 18:37:47 +0800 Subject: [PATCH 2/2] Bump version to 2.0.1 --- README.md | 2 +- cli/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 43f8e85..7e1334f 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ USAGE: auth-thu [options] online [online_options] VERSION: - 2.0.0 + 2.0.1 AUTHORS: Yuxiang Zhang diff --git a/cli/main.go b/cli/main.go index 2bbb98e..cefc5ab 100644 --- a/cli/main.go +++ b/cli/main.go @@ -409,7 +409,7 @@ func main() { auth-thu [options] logout auth-thu [options] online [online_options]`, Usage: "Authenticating utility for Tsinghua", - Version: "2.0.0", + Version: "2.0.1", HideHelp: true, Flags: []cli.Flag{ &cli.StringFlag{Name: "username, u", Usage: "your TUNET account `name`"},