<commit_before>package main

import (
	"bufio"
	"fmt"
	"github.com/viant/toolbox"
	"github.com/viant/toolbox/cred"
	"golang.org/x/crypto/ssh/terminal"
	"log"
	"os"
	"path"
	"strings"
	"syscall"
)

func printUsage() {
	fmt.Printf("Usage: secret <secretname>\n where secretnmae if name of the file in $HOME/.secret/ directory\n i.e secret scp, will be generated $HOME/.secret/scp.json\n")
}

func main() {

	if len(os.Args) < 2 || os.Args[1] == "" {
		printUsage()
		return
	}

	var secretPath = path.Join(os.Getenv("HOME"), ".secret")
	if !toolbox.FileExists(secretPath) {
		os.Mkdir(secretPath, 0744)
	}
	username, password := credentials()
	fmt.Println("")
	config := &cred.Config{
		Username: username,
		Password: password,
	}

	var privateKeyPAth = path.Join(os.Getenv("HOME"), ".ssh/id_rsa")
	if toolbox.FileExists(privateKeyPAth) {
		config.PrivateKeyPath = privateKeyPAth
	}
	var secretFile = path.Join(secretPath, fmt.Sprintf("%v.json", os.Args[1]))
	err := config.Save(secretFile)
	if err != nil {
		log.Fatal(err)
	}
}

func credentials() (string, string) {
	reader := bufio.NewReader(os.Stdin)
	fmt.Print("Enter Username: ")
	username, _ := reader.ReadString('\n')
	fmt.Print("Enter Password: ")
	bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
	if err != nil {
		log.Fatal("failed to read password %v", err)
	}
	password := string(bytePassword)
	return strings.TrimSpace(username), strings.TrimSpace(password)
}
<commit_msg>added check for secret to exclude encrytped keys<commit_after>package main

import (
	"bufio"
	"fmt"
	"github.com/viant/toolbox"
	"github.com/viant/toolbox/cred"
	"golang.org/x/crypto/ssh/terminal"
	"log"
	"os"
	"path"
	"strings"
	"syscall"
)

func printUsage() {
	fmt.Printf("Usage: secret <secretname>\n where secretnmae if name of the file in $HOME/.secret/ directory\n i.e secret scp, will be generated $HOME/.secret/scp.json\n")
}

func main() {

	if len(os.Args) < 2 || os.Args[1] == "" {
		printUsage()
		return
	}

	var secretPath = path.Join(os.Getenv("HOME"), ".secret")
	if !toolbox.FileExists(secretPath) {
		os.Mkdir(secretPath, 0744)
	}
	username, password := credentials()
	fmt.Println("")
	config := &cred.Config{
		Username: username,
		Password: password,
	}
	var privateKeyPath = path.Join(os.Getenv("HOME"), ".ssh/id_rsa")
	if toolbox.FileExists(privateKeyPath) && ! cred.IsKeyEncrypted(privateKeyPath) {
		config.PrivateKeyPath = privateKeyPath
	}
	var secretFile = path.Join(secretPath, fmt.Sprintf("%v.json", os.Args[1]))
	err := config.Save(secretFile)
	if err != nil {
		log.Fatal(err)
	}
}

func credentials() (string, string) {
	reader := bufio.NewReader(os.Stdin)
	fmt.Print("Enter Username: ")
	username, _ := reader.ReadString('\n')
	fmt.Print("Enter Password: ")
	bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
	if err != nil {
		log.Fatal("failed to read password %v", err)
	}
	password := string(<PASSWORD>)
	return strings.TrimSpace(username), strings.TrimSpace(password)
}

{'fraction_non_alphanumeric': 0.16470588235294117, 'fraction_numerical': 0.004705882352941176, 'mean_word_length': 4.5418994413407825, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7344028', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1096, 'n_words': 226}