diff options
| author | Shulhan <ms@kilabit.info> | 2023-10-06 16:35:12 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-10-06 16:35:12 +0700 |
| commit | aedc3c206dd997c6dd96ce53a807b0b6ae635b3c (patch) | |
| tree | bc152d29ee0c864437cd8204e8bdfb0cd474b7a6 /cli.go | |
| parent | 3ca05089eccb6c2e738c0a86725bd22695f5b7a7 (diff) | |
| download | gotp-aedc3c206dd997c6dd96ce53a807b0b6ae635b3c.tar.xz | |
all: implement command "get"
The "get" command get and print the issuer by its LABEL.
This will print the issuer secret, unencrypted.
Diffstat (limited to 'cli.go')
| -rw-r--r-- | cli.go | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -198,6 +198,25 @@ func (cli *Cli) Generate(label string, n int) (listOtp []string, err error) { return listOtp, nil } +// Get the stored Issuer by its label. +func (cli *Cli) Get(label string) (issuer *Issuer, err error) { + var logp = `Get` + + if cli.cfg.privateKey == nil { + cli.cfg.privateKey, err = loadPrivateKey(cli.cfg.PrivateKey, nil) + if err != nil { + return nil, fmt.Errorf(`%s: %w`, logp, err) + } + } + + issuer, err = cli.cfg.get(label) + if err != nil { + return nil, fmt.Errorf(`%s: %w`, logp, err) + } + + return issuer, nil +} + // Import the TOTP configuration from file format based on provider. func (cli *Cli) Import(providerName, file string) (n int, err error) { var ( |
