We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be nice to have a flag to do CSV output as well as the normal output, so the data can be read in more easily by scripts.
The text was updated successfully, but these errors were encountered:
index 59df65f..526016b 100644 --- a/gauth.go +++ b/gauth.go @@ -6,6 +6,7 @@ import ( "crypto/cipher" "crypto/sha256" "encoding/csv" + "flag" "fmt" "io/ioutil" "log" @@ -21,6 +22,9 @@ import ( ) func main() { + parseable := flag.Bool("csv",false,"Use to enable machine parseable output: Name, Current, Next, TTL") + flag.Parse() + user, e := user.Current() if e != nil { log.Fatal(e) @@ -75,15 +79,24 @@ func main() { currentTS, progress := gauth.IndexNow() tw := tabwriter.NewWriter(os.Stdout, 0, 8, 1, ' ', 0) - fmt.Fprintln(tw, "\tprev\tcurr\tnext") for _, record := range cfg { name, secret := record[0], record[1] prev, curr, next, err := gauth.Codes(secret, currentTS) if err != nil { log.Fatalf("Code: %v", err) } - fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", name, prev, curr, next) + if *parseable { + fmt.Fprintf(tw,"%s,%s,%s,%d\n",name, curr, next, 30 - progress) + } else { + fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", name, prev, curr, next) + } + } + + if ! *parseable { + fmt.Fprintln(tw, "\tprev\tcurr\tnext") + tw.Flush() + fmt.Printf("[%-29s]\n", strings.Repeat("=", progress)) + } else { + tw.Flush() } - tw.Flush() - fmt.Printf("[%-29s]\n", strings.Repeat("=", progress)) }
Sorry, something went wrong.
pcarrier
No branches or pull requests
It would be nice to have a flag to do CSV output as well as the normal output, so the data can be read in more easily by scripts.
The text was updated successfully, but these errors were encountered: