From 814a8822ebbb7fac8e3ec1db5354e15c651cf1e9 Mon Sep 17 00:00:00 2001 From: d-tsuji Date: Sat, 24 Oct 2020 21:59:29 +0900 Subject: [PATCH] add: log quiet mode --- cmd/awsmfa/main.go | 4 ++++ config.go | 4 ++++ run.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/cmd/awsmfa/main.go b/cmd/awsmfa/main.go index 9706512..e92f067 100644 --- a/cmd/awsmfa/main.go +++ b/cmd/awsmfa/main.go @@ -53,6 +53,10 @@ func main() { Name: "token-code", Usage: "AWS MFA token", }, + &cli.BoolFlag{ + Name: "quiet", + Usage: "log print disable", + }, }, } diff --git a/config.go b/config.go index 9426502..9e6007f 100644 --- a/config.go +++ b/config.go @@ -29,6 +29,9 @@ type Config struct { // output outConfigPath string outCredentialsPath string + + // print log config + quiet bool } func NewConfig(c *cli.Context) (*Config, error) { @@ -70,5 +73,6 @@ func NewConfig(c *cli.Context) (*Config, error) { mfaTokenCode: mfaTokenCode, outConfigPath: filepath.Join(homeDir, ".aws", "config"), outCredentialsPath: filepath.Join(homeDir, ".aws", "credentials"), + quiet: c.Bool("quiet"), }, nil } diff --git a/run.go b/run.go index 018ce56..c2e399e 100644 --- a/run.go +++ b/run.go @@ -3,6 +3,7 @@ package awsmfa import ( "context" "fmt" + "log" "os" "github.com/aws/aws-sdk-go/aws" @@ -16,6 +17,9 @@ func Run(ctx context.Context, c *Config) error { SerialNumber: aws.String(c.serialNumber), TokenCode: aws.String(c.mfaTokenCode), }) + if !c.quiet { + log.Println(out) + } if err != nil { return err }