Skip to content

Commit

Permalink
v0.13 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Jeannopoulos committed Sep 1, 2020
1 parent 09aa371 commit 604e745
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
25 changes: 16 additions & 9 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,47 +94,53 @@ func (ts Tokens) String(i int) string {
// Len - number of Token results
func (ts Tokens) Len() int { return len(ts) }

func loadCachedTokens() (tokens []*Token, err error) {
func loadCachedTokens() ([]*Token, error) {
fpath, err := ConfigPath(cacheFileName)
if err != nil {
return
return nil, err
}

f, err := os.Open(fpath)
if err != nil {
return
return nil, err
}

defer f.Close()

tokens := []*Token{}
err = json.NewDecoder(f).Decode(tokens)
if err != nil {
return nil, err
}

if verbose {
fmt.Printf("Loaded cached providers from %v\n", fpath)
}
return
return tokens, err
}

func saveTokens(tks []*Token) (err error) {
func saveTokens(tks []*Token) error {
regrPath, err := ConfigPath(cacheFileName)
if err != nil {
return
return err
}

f, err := os.OpenFile(regrPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
if err != nil {
return
return err
}

defer f.Close()
err = json.NewEncoder(f).Encode(tks)

if err != nil {
fmt.Printf("Error saving tokens: %v\n", err)
return
return err
}
if verbose {
fmt.Printf("Saved tokens to file: %v\n", regrPath)
}
return
return nil
}

func getTokensFromAuthyServer(devInfo *DeviceRegistration) ([]*Token, error) {
Expand Down Expand Up @@ -295,6 +301,7 @@ func ConfigPath(fname string) (string, error) {

return filepath.Join(devPath, fname), nil
}

func promptAccountInfo() (phoneCC int, mobile string, err error) {
var (
sc = bufio.NewScanner(os.Stdin)
Expand Down
3 changes: 2 additions & 1 deletion cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ func execCmdRun(tokenName, script, replacementToken string, dryRun bool) {
fmt.Printf("code: %v\n", code)
fmt.Printf("timeLeft: %v\n", timeLeft)
fmt.Printf("orig script: %v\n", script)
fmt.Printf("script: [%v]\n", strings.Join(args, " "))
}

fmt.Printf("script: [%v]\n", strings.Join(args, " "))

if dryRun {
fmt.Printf("dry run exiting\n")
return
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

var (
// Version version tag
Version = "v0.12"
Version = "v0.13"

// BuildDate date string of when build was performed filled in by -X compile flag
BuildDate string
Expand Down

0 comments on commit 604e745

Please sign in to comment.