mirror of https://github.com/mitchell/selfpass.git
Revert "Update get command to allow multiple creds;"
This reverts commit b9c233b6b3
.
This commit is contained in:
parent
b9c233b6b3
commit
5968ac2df9
|
@ -72,7 +72,7 @@ password.`,
|
||||||
key := cfg.GetString(clitypes.KeyPrivateKey)
|
key := cfg.GetString(clitypes.KeyPrivateKey)
|
||||||
keypass := crypto.GeneratePBKDF2Key([]byte(masterpass), []byte(key))
|
keypass := crypto.GeneratePBKDF2Key([]byte(masterpass), []byte(key))
|
||||||
|
|
||||||
prompt = &survey.Confirm{Message: "Generate a random password?", Default: true}
|
prompt = &survey.Confirm{Message: "Do you want a random password?", Default: true}
|
||||||
check(survey.AskOne(prompt, &newpass, nil))
|
check(survey.AskOne(prompt, &newpass, nil))
|
||||||
|
|
||||||
if newpass {
|
if newpass {
|
||||||
|
@ -152,7 +152,7 @@ password.`,
|
||||||
|
|
||||||
fmt.Println(c)
|
fmt.Println(c)
|
||||||
|
|
||||||
prompt = &survey.Confirm{Message: "Clear the clipboard?", Default: true}
|
prompt = &survey.Confirm{Message: "Do you want to clear the clipboard?", Default: true}
|
||||||
check(survey.AskOne(prompt, &cleancb, nil))
|
check(survey.AskOne(prompt, &cleancb, nil))
|
||||||
|
|
||||||
if cleancb {
|
if cleancb {
|
||||||
|
|
|
@ -9,10 +9,8 @@ import (
|
||||||
"github.com/atotto/clipboard"
|
"github.com/atotto/clipboard"
|
||||||
"github.com/pquerna/otp/totp"
|
"github.com/pquerna/otp/totp"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
|
||||||
"gopkg.in/AlecAivazis/survey.v1"
|
"gopkg.in/AlecAivazis/survey.v1"
|
||||||
|
|
||||||
"github.com/mitchell/selfpass/services/credentials/types"
|
|
||||||
"github.com/mitchell/selfpass/sp/crypto"
|
"github.com/mitchell/selfpass/sp/crypto"
|
||||||
clitypes "github.com/mitchell/selfpass/sp/types"
|
clitypes "github.com/mitchell/selfpass/sp/types"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +25,12 @@ func makeGet(repo clitypes.ConfigRepo, initClient credentialsClientInit) *cobra.
|
||||||
decrypting password.`,
|
decrypting password.`,
|
||||||
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
var (
|
||||||
|
copyPass bool
|
||||||
|
cleancb bool
|
||||||
|
prompt survey.Prompt
|
||||||
|
)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*60)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*60)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -36,25 +40,6 @@ decrypting password.`,
|
||||||
|
|
||||||
cred := selectCredential(client, flags.sourceHost)
|
cred := selectCredential(client, flags.sourceHost)
|
||||||
|
|
||||||
for getAnother := getCredential(cred, masterpass, cfg); getAnother; {
|
|
||||||
cred := selectCredential(client, flags.sourceHost)
|
|
||||||
getAnother = getCredential(cred, masterpass, cfg)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
flags.register(getCmd)
|
|
||||||
|
|
||||||
return getCmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCredential(cred types.Credential, masterpass string, cfg *viper.Viper) (again bool) {
|
|
||||||
var (
|
|
||||||
copyPass bool
|
|
||||||
cleancb bool
|
|
||||||
prompt survey.Prompt
|
|
||||||
)
|
|
||||||
|
|
||||||
fmt.Println(cred)
|
fmt.Println(cred)
|
||||||
|
|
||||||
check(clipboard.WriteAll(string(cred.Primary)))
|
check(clipboard.WriteAll(string(cred.Primary)))
|
||||||
|
@ -98,16 +83,16 @@ func getCredential(cred types.Credential, masterpass string, cfg *viper.Viper) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = &survey.Confirm{Message: "Clear the clipboard?", Default: true}
|
prompt = &survey.Confirm{Message: "Do you want to clear the clipboard?", Default: true}
|
||||||
check(survey.AskOne(prompt, &cleancb, nil))
|
check(survey.AskOne(prompt, &cleancb, nil))
|
||||||
|
|
||||||
if cleancb {
|
if cleancb {
|
||||||
check(clipboard.WriteAll(" "))
|
check(clipboard.WriteAll(" "))
|
||||||
fmt.Println("Clipboard cleared.")
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = &survey.Confirm{Message: "Get another credential?", Default: true}
|
flags.register(getCmd)
|
||||||
check(survey.AskOne(prompt, &again, nil))
|
|
||||||
|
|
||||||
return again
|
return getCmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ password.`,
|
||||||
|
|
||||||
if newpass {
|
if newpass {
|
||||||
var randpass bool
|
var randpass bool
|
||||||
prompt = &survey.Confirm{Message: "Generate a random password?", Default: true}
|
prompt = &survey.Confirm{Message: "Do you want a random password?", Default: true}
|
||||||
check(survey.AskOne(prompt, &randpass, nil))
|
check(survey.AskOne(prompt, &randpass, nil))
|
||||||
|
|
||||||
if randpass {
|
if randpass {
|
||||||
|
@ -181,7 +181,7 @@ password.`,
|
||||||
|
|
||||||
fmt.Println(c)
|
fmt.Println(c)
|
||||||
|
|
||||||
prompt = &survey.Confirm{Message: "Clear the clipboard?", Default: true}
|
prompt = &survey.Confirm{Message: "Do you want to clear the clipboard?", Default: true}
|
||||||
check(survey.AskOne(prompt, &cleancb, nil))
|
check(survey.AskOne(prompt, &cleancb, nil))
|
||||||
|
|
||||||
if cleancb {
|
if cleancb {
|
||||||
|
|
Loading…
Reference in New Issue