<commit_before>package main

import (
	"context"
	"fmt"
	"os"
	"text/template"

	bloomsky "github.com/patrickalin/bloomsky-api-go"
	"github.com/sirupsen/logrus"
)

type console struct {
	in           chan bloomsky.Bloomsky
	testTemplate *template.Template
}

//InitConsole listen on the chanel
func createConsole(messages chan bloomsky.Bloomsky) (console, error) {
	f := map[string]interface{}{"T": config.translateFunc}
	c := console{in: messages, testTemplate: GetTemplate("bloomsky.txt", "tmpl/bloomsky.txt", f, config.dev)}
	logrus.WithFields(logrus.Fields{
		"fct": "exportConsole.initConsole",
	}).Info("Init console")
	return c, nil
}

func (c *console) listen(context context.Context) {
	go func() {

		/*
			TODO

			g, err := gocui.NewGui(gocui.OutputNormal)
			if err != nil {
				log.Panicln(err)
			}
			defer g.Close()

			g.SetManagerFunc(layout)

			if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
				log.Panicln(err)
			}

			if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
				log.Panicln(err)
			}*/

		log.Debug("Init the queue to receive message to export to console")

		for {
			msg := <-c.in

			if err := c.testTemplate.Execute(os.Stdout, msg); err != nil {
				fmt.Printf("%v", err)
			}
		}

	}()

}

/*
func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("hello", maxX/2-7, maxY/2, maxX/2+7, maxY/2+2); err != nil {<commit_msg>log + typo<commit_after>package main

import (
	"context"
	"fmt"
	"os"
	"text/template"

	bloomsky "github.com/patrickalin/bloomsky-api-go"
	"github.com/sirupsen/logrus"
)

type console struct {
	in           chan bloomsky.Bloomsky
	textTemplate *template.Template
}

//InitConsole listen on the chanel
func createConsole(messages chan bloomsky.Bloomsky) (console, error) {
	f := map[string]interface{}{"T": config.translateFunc}
	//Get template
	c := console{in: messages, textTemplate: GetTemplate("bloomsky.txt", "tmpl/bloomsky.txt", f, config.dev)}
	logrus.WithFields(logrus.Fields{
		"fct": "exportConsole.initConsole",
	}).Info("Init console")
	return c, nil
}

func (c *console) listen(context context.Context) {
	go func() {

		/*
			TODO

			g, err := gocui.NewGui(gocui.OutputNormal)
			if err != nil {
				log.Panicln(err)
			}
			defer g.Close()

			g.SetManagerFunc(layout)

			if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
				log.Panicln(err)
			}

			if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
				log.Panicln(err)
			}*/

		logrus.WithFields(logrus.Fields{
			"fct": "exportConsole.initConsole",
		}).Info("Init the queue console to display message")

		for {
			msg := <-c.in

			if err := c.textTemplate.Execute(os.Stdout, msg); err != nil {
				fmt.Printf("%v", err)
			}
		}

	}()

}

/*
func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("hello", maxX/2-7, maxY/2, maxX/2+7, maxY/2+2); err != nil {
{'fraction_non_alphanumeric': 0.16621253405994552, 'fraction_numerical': 0.004768392370572207, 'mean_word_length': 3.45, 'pattern_counts': {'":': 5, '<': 5, '<?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': '757553', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1130, 'n_words': 245}