diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ef251da..57c349b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -50,6 +50,6 @@ jobs: - name: Run go vet run: go vet ./... - name: Run go build - run: go build ./... + run: go build - name: Run tests run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... diff --git a/README.md b/README.md new file mode 100644 index 0000000..6fac52b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +### gootp + +gootp is a terminal-based 2FA (Two-Factor Authentication) app. + +[![asciicast](https://asciinema.org/a/s9eF7EbqgnCkoLVwbv0TE0a8Y.svg)](https://asciinema.org/a/s9eF7EbqgnCkoLVwbv0TE0a8Y) + +## Features +- Supported algorithms: TOTP +- Compatible with [andOTP](https://github.com/andOTP/andOTP) file format +- Allows to encrypt/decrypt andOTP files on your PC + +## Installation + +Requirements: +1. Go 1.18+ +2. [Exported andOTP file](https://github.com/andOTP/andOTP#backups=) + +```shell +go install github.com/Kichiyaki/gootp@latest +cp /path/to/andotp/file ~/.otp_accounts.json # !IMPORTANT! this file must be encrypted +``` +## Examples + +```shell +gootp # show OTP list +gootp -h # help for gootp +gootp -p /path/to/andotp/file/.otp_accounts.json # override default path +gootp --password xxx # specify encryption password via flag +gootp -p /path/to/andotp/file/.otp_accounts.json encrypt -o /output/.otp_accounts.json.aes # encrypt file +gootp -p /path/to/andotp/file/.otp_accounts.json decrypt -o /output/.otp_accounts.json.aes # decrypt file +``` diff --git a/main.go b/main.go index 685a569..5922b24 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "log" "os" "path" + "runtime/debug" "syscall" tea "github.com/charmbracelet/bubbletea" @@ -14,8 +15,6 @@ import ( "golang.org/x/term" ) -var Version = "development" - func main() { app, err := newApp() if err != nil { @@ -32,10 +31,12 @@ func newApp() (*cli.App, error) { return nil, fmt.Errorf("couldn't get user home dir: %w", err) } + buildInfo, _ := debug.ReadBuildInfo() + return &cli.App{ Name: "gootp", - Usage: "2FA App compatible with andOTP backup file format", - Version: Version, + Usage: "Two-Factor Authentication (2FA) App compatible with andOTP file format", + Version: buildInfo.Main.Version, Action: func(c *cli.Context) error { password, err := getPassword(c) if err != nil { @@ -85,7 +86,7 @@ func newApp() (*cli.App, error) { func newDecryptCommand() *cli.Command { return &cli.Command{ Name: "decrypt", - Usage: "Decrypts the specified backup file", + Usage: "Decrypts the specified file", Action: newEncryptDecryptActionFunc(internal.Decrypt), Flags: []cli.Flag{ &cli.StringFlag{ @@ -101,7 +102,7 @@ func newDecryptCommand() *cli.Command { func newEncryptCommand() *cli.Command { return &cli.Command{ Name: "encrypt", - Usage: "Encrypts the specified file file using AES-256", + Usage: "Encrypts the specified file", Action: newEncryptDecryptActionFunc(internal.Encrypt), Flags: []cli.Flag{ &cli.StringFlag{