<commit_before>package main

import (
	"bufio"
	"fmt"
	"os"

	"github.com/Nhanderu/gridt"
	"github.com/alecthomas/kingpin"
	"golang.org/x/crypto/ssh/terminal"
)

const (
	topToBottom = "top-to-bottom"
	leftToRight = "left-to-right"
)

var (
	args      *[]string
	file      *string
	separator *string
	direction *string
)

func init() {

	kingpin.CommandLine.HelpFlag.Short('h')
	kingpin.Version("2.0.0").VersionFlag.Short('v')

	args = kingpin.Flag("args", "Use the given arguments as values.").Short('a').Strings()
	file = kingpin.Flag("file", "Get values as lines from file.").Short('f').String()
	separator = kingpin.
		Flag("separator", "What separates every value column.").
		Short('s').
		Default("  ").
		String()
	direction = kingpin.
		Flag("direction", `Whether it writes from "top-to-bottom" or "left-to-right".`).
		Short('d').
		Default(topToBottom).
		Enum(topToBottom, leftToRight)

	kingpin.Parse()
}

func main() {

	if len(*args) != 0 && *file != "" {
		eprintln(`"--args" and "--file" shouldn't be used together.`)
		os.Exit(1)
	}

	width, _, err := terminal.GetSize(0)
	if err != nil {
		eprintln(err.Error())
		os.Exit(1)
	}

	var scanner *bufio.Scanner

	var values []string
	switch {

	case len(*args) != 0:
		values = *args

	case *file != "":
		f, err := os.Open(*file)
		if err != nil {
			eprintf("Error %s.", err.Error())
			os.Exit(1)
		}
		defer f.Close()
		scanner = bufio.NewScanner(f)

	default:
		scanner = bufio.NewScanner(os.Stdin)

	}

	if scanner != nil {
		scanner.Split(bufio.ScanLines)
		for scanner.Scan() {
			values = append(values, scanner.Text())
		}
	}

	d := gridt.TopToBottom
	if *direction == leftToRight {
		d = gridt.LeftToRight
	}

	if len(values) == 0 {
		eprintln("No values were given.")
		os.Exit(1)
	}

	grid, ok := gridt.New(d, *separator, values...).FitIntoWidth(width)<commit_msg>Remove args flag<commit_after>package main

import (
	"bufio"
	"fmt"
	"os"

	"github.com/Nhanderu/gridt"
	"github.com/alecthomas/kingpin"
	"golang.org/x/crypto/ssh/terminal"
)

const (
	topToBottom = "top-to-bottom"
	leftToRight = "left-to-right"
)

var (
	args      *[]string
	file      *string
	separator *string
	direction *string
)

func init() {

	kingpin.CommandLine.HelpFlag.Short('h')
	kingpin.Version("2.0.0").VersionFlag.Short('v')

	file = kingpin.Flag("file", "Get values as lines from file.").Short('f').String()
	separator = kingpin.
		Flag("separator", "What separates every value column.").
		Short('s').
		Default("  ").
		String()
	direction = kingpin.
		Flag("direction", `Whether it writes from "top-to-bottom" or "left-to-right".`).
		Short('d').
		Default(topToBottom).
		Enum(topToBottom, leftToRight)

	kingpin.Parse()
}

func main() {

	width, _, err := terminal.GetSize(0)
	if err != nil {
		eprintln(err.Error())
		os.Exit(1)
	}

	var scanner *bufio.Scanner
	if *file != "" {
		f, err := os.Open(*file)
		if err != nil {
			eprintf("Error %s.", err.Error())
			os.Exit(1)
		}
		defer f.Close()
		scanner = bufio.NewScanner(f)
	} else {
		scanner = bufio.NewScanner(os.Stdin)
	}

	var values []string
	if scanner != nil {
		scanner.Split(bufio.ScanLines)
		for scanner.Scan() {
			values = append(values, scanner.Text())
		}
	}

	if len(values) == 0 {
		eprintln("No values were given.")
		os.Exit(1)
	}

	d := gridt.TopToBottom
	if *direction == leftToRight {
		d = gridt.LeftToRight
	}

	grid, ok := gridt.New(d, *separator, values...).FitIntoWidth(width)
{'fraction_non_alphanumeric': 0.1778102189781022, 'fraction_numerical': 0.005547445255474452, 'mean_word_length': 3.4784313725490197, 'pattern_counts': {'":': 1, '<': 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': '3662034', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1312, 'n_words': 277}