<commit_before>package main

import (
	"fmt"
	"io"
	"os"

	"github.com/urfave/cli"

	"github.com/polydawn/refmt/cbor"
	"github.com/polydawn/refmt/pretty"
	"github.com/polydawn/refmt/shared"
)

func main() {
	os.Exit(Main(os.Args, os.Stdin, os.Stdout, os.Stderr))
}

func Main(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
	app := cli.NewApp()
	app.Name = "refmt"
	app.Authors = []cli.Author{
		cli.Author{Name: "<NAME>", Email: "<EMAIL>"},
	}
	app.Commands = []cli.Command{
		cli.Command{
			Category: "convert",
			Name:     "hex=cbor=pretty",
			Usage:    "read cbor in hex, then pretty print it",
			Action: func(c *cli.Context) error {
				return shared.TokenPump{
					cbor.NewDecoder(hexReader(stdin)),
					pretty.NewEncoder(stdout),
				}.Run()
			},
		},
	}
	app.Writer = stdout
	app.ErrWriter = stderr
	err := app.Run(args)
	if err != nil {<commit_msg>cmd: more prettyprint and converters.<commit_after>package main

import (
	"fmt"
	"io"
	"os"

	"github.com/urfave/cli"

	"github.com/polydawn/refmt/cbor"
	"github.com/polydawn/refmt/json"
	"github.com/polydawn/refmt/pretty"
	"github.com/polydawn/refmt/shared"
)

func main() {
	os.Exit(Main(os.Args, os.Stdin, os.Stdout, os.Stderr))
}

func Main(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
	app := cli.NewApp()
	app.Name = "refmt"
	app.Authors = []cli.Author{
		cli.Author{Name: "<NAME>", Email: "<EMAIL>"},
	}
	app.Commands = []cli.Command{
		cli.Command{
			Category: "prettyprint",
			Name:     "json=pretty",
			Usage:    "read json, then pretty print it",
			Action: func(c *cli.Context) error {
				return shared.TokenPump{
					json.NewDecoder(stdin),
					pretty.NewEncoder(stdout),
				}.Run()
			},
		},
		cli.Command{
			Category: "prettyprint",
			Name:     "hex=cbor=pretty",
			Usage:    "read cbor in hex, then pretty print it",
			Action: func(c *cli.Context) error {
				return shared.TokenPump{
					cbor.NewDecoder(hexReader(stdin)),
					pretty.NewEncoder(stdout),
				}.Run()
			},
		},
		cli.Command{
			Category: "convert",
			Name:     "json=cbor",
			Usage:    "read json, emit equivalent cbor",
			Action: func(c *cli.Context) error {
				return shared.TokenPump{
					json.NewDecoder(stdin),
					cbor.NewEncoder(stdout),
				}.Run()
			},
		},
		cli.Command{
			Category: "convert",
			Name:     "hex=cbor=json",
			Usage:    "read cbor in hex, emit equivalent json",
			Action: func(c *cli.Context) error {
				return shared.TokenPump{
					cbor.NewDecoder(hexReader(stdin)),
					json.NewEncoder(stdout),
				}.Run()
			},
		},
	}
	app.Writer = stdout
	app.ErrWriter = stderr
	err := app.Run(args)
	if err != nil {
{'fraction_non_alphanumeric': 0.16527987897125568, 'fraction_numerical': 0.0, 'mean_word_length': 3.252411575562701, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2048611', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1016, 'n_words': 206}