<commit_before>package cli

import (
	"bytes"
	"code.google.com/p/gopass"
	"fmt"
	"net/http"
	"net/http/httputil"
	"os"
	"strings"
	// "github.com/kr/pretty"
)

func (c *Cli) CmdLogin() error {
	uri := fmt.Sprintf("%s/rest/auth/1/session", c.endpoint)
	for true {
		req, _ := http.NewRequest("GET", uri, nil)
		user, _ := c.opts["user"].(string)

		prompt := fmt.Sprintf("Enter Password for %s: ", user)
		passwd, _ := gopass.GetPass(prompt)

		req.SetBasicAuth(user, passwd)
		log.Info("%s %s", req.Method, req.URL.String())
		if resp, err := c.makeRequest(req); err != nil {
			return err
		} else {
			out, _ := httputil.DumpResponse(resp, true)
			log.Debug("%s", out)
			if resp.StatusCode == 403 {
				// probably got this, need to redirect the user to login manually<commit_msg>replace dead/deprecated code.google.com/p/gopass with golang.org/x/crypto/ssh/terminal for reading password from stdin<commit_after>package cli

import (
	"bytes"
	"fmt"
	"golang.org/x/crypto/ssh/terminal"
	"net/http"
	"net/http/httputil"
	"os"
	"strings"
	// "github.com/kr/pretty"
)

func (c *Cli) CmdLogin() error {
	uri := fmt.Sprintf("%s/rest/auth/1/session", c.endpoint)
	for true {
		req, _ := http.NewRequest("GET", uri, nil)
		user, _ := c.opts["user"].(string)

		fmt.Printf("Enter Password for %s: ", user)
		pwbytes, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
		passwd := string(pwbytes)

		req.SetBasicAuth(user, passwd)
		log.Info("%s %s", req.Method, req.URL.String())
		if resp, err := c.makeRequest(req); err != nil {
			return err
		} else {
			out, _ := httputil.DumpResponse(resp, true)
			log.Debug("%s", out)
			if resp.StatusCode == 403 {
				// probably got this, need to redirect the user to login manually
{'fraction_non_alphanumeric': 0.17616279069767443, 'fraction_numerical': 0.004651162790697674, 'mean_word_length': 3.651351351351351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5859915', 'n_tokens_mistral': 711, 'n_tokens_neox': 651, 'n_words': 147}