Skip to content
New issue

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

Remove cnlubo/promptx and update dependencies #101

Merged
merged 1 commit into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master - unreleased

ENHANCEMENTS:

* Remove bad dependency and patch dependencies ([#101](https://github.com/fishi0x01/vsh/pull/101))

## v0.12.1 (October, 06, 2021)

ENHANCEMENTS:
Expand Down
4 changes: 1 addition & 3 deletions cli/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"fmt"

"github.com/cnlubo/promptx"
"github.com/fishi0x01/vsh/client"
"github.com/fishi0x01/vsh/log"
)
Expand Down Expand Up @@ -104,8 +103,7 @@ func (cmd *AddCommand) addKeyValue(path string, key string, value string) error
data[key] = value
secret.SetData(data)
if cmd.args.Confirm == false && cmd.args.DryRun == false {
p := promptx.NewDefaultConfirm("Write changes to Vault?", false)
result, err := p.Run()
result, err := askForConfirmation("Write changes to Vault?")
if err != nil {
return fmt.Errorf("Error prompting for confirmation")
}
Expand Down
35 changes: 35 additions & 0 deletions cli/confirmation_prompt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cli

import (
"bufio"
"fmt"
"os"
"strings"

"github.com/fatih/color"
)

// Inspiration from: https://gist.github.com/r0l1/3dcbb0c8f6cfe9c66ab8008f55f8f28b
func askForConfirmation(s string) (bool, error) {
c := color.New(color.FgCyan)
reader := bufio.NewReader(os.Stdin)

for i := 0; i < 2; i++ {
c.Printf("%s [y/N]: ", s)

response, err := reader.ReadString('\n')
if err != nil {
return false, fmt.Errorf("Error reading input")
}

response = strings.ToLower(strings.TrimSpace(response))

if response == "y" || response == "yes" {
return true, nil
} else if response == "n" || response == "no" {
return false, nil
}
}

return false, nil
}
4 changes: 1 addition & 3 deletions cli/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"

"github.com/cnlubo/promptx"
"github.com/fishi0x01/vsh/client"
"github.com/fishi0x01/vsh/log"
)
Expand Down Expand Up @@ -152,8 +151,7 @@ func (cmd *ReplaceCommand) findMatches(filePaths []string) (matchesByPath map[st
func (cmd *ReplaceCommand) commitMatches(matchesByPath map[string][]*Match) int {
if len(matchesByPath) > 0 {
if cmd.args.Confirm == false && cmd.args.DryRun == false {
p := promptx.NewDefaultConfirm("Write changes to Vault?", false)
result, err := p.Run()
result, err := askForConfirmation("Write changes to Vault?")
if err != nil {
return 1
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ require (
github.com/alexflint/go-arg v1.3.0
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883
github.com/c-bata/go-prompt v0.2.3
github.com/cnlubo/promptx v0.0.0-20190626092511-0fff67c60c75
github.com/cosiner/argv v0.1.0
github.com/fatih/color v1.11.0
github.com/fatih/color v1.13.0
github.com/fatih/structs v1.1.0
github.com/hashicorp/vault v1.8.3
github.com/hashicorp/vault v1.8.4
github.com/hashicorp/vault/api v1.1.2-0.20210713235431-1fc8af4c041f
github.com/logrusorgru/aurora v0.0.0-20190803045625-94edacc10f9b
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mattn/go-tty v0.0.0-20190424173100-523744f04859 // indirect
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
Expand Down
45 changes: 21 additions & 24 deletions go.sum

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions vendor/github.com/cnlubo/promptx/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/cnlubo/promptx/LICENSE

This file was deleted.

15 changes: 0 additions & 15 deletions vendor/github.com/cnlubo/promptx/README.md

This file was deleted.

121 changes: 0 additions & 121 deletions vendor/github.com/cnlubo/promptx/codes.go

This file was deleted.

Loading