Skip to content

Commit

Permalink
add: log quiet mode
Browse files Browse the repository at this point in the history
  • Loading branch information
d-tsuji committed Oct 24, 2020
1 parent e7bccfa commit 814a882
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/awsmfa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func main() {
Name: "token-code",
Usage: "AWS MFA token",
},
&cli.BoolFlag{
Name: "quiet",
Usage: "log print disable",
},
},
}

Expand Down
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type Config struct {
// output
outConfigPath string
outCredentialsPath string

// print log config
quiet bool
}

func NewConfig(c *cli.Context) (*Config, error) {
Expand Down Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package awsmfa
import (
"context"
"fmt"
"log"
"os"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -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
}
Expand Down

0 comments on commit 814a882

Please sign in to comment.