Use an external command for clipboard

This commit is contained in:
2025-01-30 08:07:05 -06:00
parent e8bf42dd17
commit cf346ed025
5 changed files with 18 additions and 56 deletions

View File

@@ -12,7 +12,6 @@ import (
gap "github.com/muesli/go-app-paths"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.design/x/clipboard"
)
// rootCmd represents the base command when called without any subcommands
@@ -47,10 +46,6 @@ func Execute() {
}
func init() {
err := clipboard.Init()
if err != nil {
os.Exit(1)
}
rootCmd.Version = Version
initConfig()
}
@@ -89,7 +84,7 @@ func initConfig() {
if createConfig {
_, err := os.Stat(firstDir)
if os.IsNotExist(err) {
err := os.Mkdir(firstDir, 0755)
err := os.Mkdir(firstDir, 0o755)
if err != nil {
fmt.Println(err)
os.Exit(1)
@@ -105,5 +100,10 @@ func initConfig() {
db = util.PromptUserTrimmed("Path to KeePass Database:")
viper.Set("database", db)
}
cbCmd := viper.GetString("clipboard-command")
if cbCmd == "" {
cbCmd = util.PromptUserTrimmed("Copy to Clipboard Command:")
viper.Set("clipboard-command", cbCmd)
}
viper.WriteConfig()
}

View File

@@ -5,8 +5,10 @@ package cmd
import (
"fmt"
"strings"
"git.bullercodeworks.com/brian/keepass-cli/models"
"git.bullercodeworks.com/brian/keepass-cli/util"
"github.com/spf13/cobra"
)
@@ -24,6 +26,7 @@ func init() {
func runTestCmd(_ *cobra.Command, args []string) error {
models.LoadFrequencies()
fmt.Println(args)
util.WriteToClipboard(strings.Join(args, " "))
/*
var db *models.KeePassDB
pass, err := util.PromptUserForPassword("Master Password")