<commit_before>package main

import (
	"errors"
	"fmt"
	"os"
	"time"

	"github.com/dickeyxxx/speakeasy"
	"github.com/franela/goreq"
)

var loginTopic = &Topic{
	Name:        "login",
	Description: "Login with your Heroku credentials.",
}

var loginCmd = &Command{
	Topic:       "login",
	Description: "Login with your Heroku credentials.",
	Run: func(ctx *Context) {
		login()
	},
}

func login() {
	Println("Enter your Heroku credentials.")
	email := getString("Email: ")
	password := getPassword()

	token, err := createOauthToken(email, password, "")
	if err != nil {
		PrintError(err)
		return
	}
	saveOauthToken(email, token)
	Println("Logged in")
}

func saveOauthToken(email, token string) {
	netrc := getNetrc()
	netrc.NewMachine(herokuAPIHost(), email, token, "")
	netrc.NewMachine(herokuGitHost(), email, token, "")
	ExitIfError(netrc.Save())
}

func getString(prompt string) string {
	var s string
	Err(prompt)
	if _, err := fmt.Scanln(&s); err != nil {
		if err.Error() == "unexpected newline" {
			return getString(prompt)
		}
		if err.Error() == "EOF" {
			Errln()
			os.Exit(1)
		}<commit_msg>set netrc filename in case it does not exist<commit_after>package main

import (
	"errors"
	"fmt"
	"os"
	"time"

	"github.com/dickeyxxx/speakeasy"
	"github.com/franela/goreq"
)

var loginTopic = &Topic{
	Name:        "login",
	Description: "Login with your Heroku credentials.",
}

var loginCmd = &Command{
	Topic:       "login",
	Description: "Login with your Heroku credentials.",
	Run: func(ctx *Context) {
		login()
	},
}

func login() {
	Println("Enter your Heroku credentials.")
	email := getString("Email: ")
	password := <PASSWORD>()

	token, err := createOauthToken(email, password, "")
	if err != nil {
		PrintError(err)
		return
	}
	saveOauthToken(email, token)
	Println("Logged in")
}

func saveOauthToken(email, token string) {
	netrc := getNetrc()
	netrc.Filename = netrcPath()
	netrc.NewMachine(herokuAPIHost(), email, token, "")
	netrc.NewMachine(herokuGitHost(), email, token, "")
	ExitIfError(netrc.Save())
}

func getString(prompt string) string {
	var s string
	Err(prompt)
	if _, err := fmt.Scanln(&s); err != nil {
		if err.Error() == "unexpected newline" {
			return getString(prompt)
		}
		if err.Error() == "EOF" {
			Errln()
			os.Exit(1)
		}
{'fraction_non_alphanumeric': 0.15641476274165203, 'fraction_numerical': 0.0008787346221441124, 'mean_word_length': 4.128378378378378, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6103316', 'n_tokens_mistral': 868, 'n_tokens_neox': 828, 'n_words': 200}