<commit_before>package print

import (
	"fmt"
	"os"
	"strings"
	"time"

	"github.com/dustin/go-humanize"
	"github.com/go-errors/errors"
	"github.com/markelog/curse"
	"github.com/mgutz/ansi"
	"gopkg.in/cavaliercoder/grab.v1"

	"github.com/markelog/eclectica/cmd/print/spinner"
	"github.com/markelog/eclectica/variables"
)

var (
	Gray    = ansi.ColorCode("240")
	White   = ansi.ColorCode("white+b")
	Reset   = ansi.ColorCode("reset")
	Timeout = 200 * time.Millisecond
)

func InStyle(name, entity string) {
	name = ansi.Color(name, "white+b")
	entity = ansi.Color(" "+entity+" ", "cyan+h")

	fmt.Print(name, entity)
}

func InStyleln(name, entity string) {
	InStyle(name, entity)
	fmt.Println()
}

func Version(args ...interface{}) {
	var color string
	version := args[0].(string)

	if len(args) == 1 {
		color = Gray
	} else {
		color = ansi.ColorCode(args[1].(string))
	}

	fmt.Println(color, "  ", version, Reset)
}

func CurrentVersion(version string) {
	fmt.Println(ansi.Color("  ♥ "+version, "cyan"))
}

func Error(err error) {
	if err == nil {
		return
	}

	fmt.Println()
	fmt.Print(ansi.Color("> ", "red"))

	fmt.Fprintf(os.Stderr, "%v", err)

	if variables.IsDebug() {
		fmt.Println(errors.Wrap(err, 2).ErrorStack())
	}

	fmt.Println()
	fmt.Println()

	os.Exit(1)
}

func Download(response *grab.Response, version string) string {
	Error(response.Error)

	cursed, _ := curse.New()

	sizeAndTransfer := func() (size, transfer string) {
		size = humanize.Bytes(response.Size)

		transfer = humanize.Bytes(response.BytesTransferred())
		transfer = strings.Replace(transfer, " MB", "", 1)

		return
	}

	before := func() {}

	prefix := func() {
		Error(response.Error)
<commit_msg>Use only stderr for support errors output<commit_after>package print

import (
	"fmt"
	"log"
	"os"
	"strings"
	"time"

	"github.com/dustin/go-humanize"
	"github.com/go-errors/errors"
	"github.com/markelog/curse"
	"github.com/mgutz/ansi"
	"gopkg.in/cavaliercoder/grab.v1"

	"github.com/markelog/eclectica/cmd/print/spinner"
	"github.com/markelog/eclectica/variables"
)

var (
	Gray    = ansi.ColorCode("240")
	White   = ansi.ColorCode("white+b")
	Reset   = ansi.ColorCode("reset")
	Timeout = 200 * time.Millisecond
)

func InStyle(name, entity string) {
	name = ansi.Color(name, "white+b")
	entity = ansi.Color(" "+entity+" ", "cyan+h")

	fmt.Print(name, entity)
}

func InStyleln(name, entity string) {
	InStyle(name, entity)
	fmt.Println()
}

func Version(args ...interface{}) {
	var color string
	version := args[0].(string)

	if len(args) == 1 {
		color = Gray
	} else {
		color = ansi.ColorCode(args[1].(string))
	}

	fmt.Println(color, "  ", version, Reset)
}

func CurrentVersion(version string) {
	fmt.Println(ansi.Color("  ♥ "+version, "cyan"))
}

func Error(err error) {
	if err == nil {
		return
	}

	stderr := log.New(os.Stderr, "", 0)

	stderr.Println()
	stderr.Print(ansi.Color("> ", "red"))

	stderr.Printf("%v", err)
	stderr.Println()

	if variables.IsDebug() {
		stderr.Println(errors.Wrap(err, 2).ErrorStack())
	}

	stderr.Println()
	stderr.Println()

	os.Exit(1)
}

func Download(response *grab.Response, version string) string {
	Error(response.Error)

	cursed, _ := curse.New()

	sizeAndTransfer := func() (size, transfer string) {
		size = humanize.Bytes(response.Size)

		transfer = humanize.Bytes(response.BytesTransferred())
		transfer = strings.Replace(transfer, " MB", "", 1)

		return
	}

	before := func() {}

	prefix := func() {
		Error(response.Error)

{'fraction_non_alphanumeric': 0.17507931929622153, 'fraction_numerical': 0.007787712719930776, 'mean_word_length': 4.092511013215859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '464142', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1341, 'n_words': 246}