<commit_before>package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
	"os"

	"github.com/mmcloughlin/globe"
	"io"
)

// locationsCmd represents the locations command
var locationsCmd = &cobra.Command{
	Use:   "locations",
	Short: "TODO",
	Long: `TODO
.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		out, err := cmd.Flags().GetString("output")
		if err != nil {
			return fmt.Errorf("cannot determine output: %s", err)
		}
		g := globe.New()

		g.DrawGraticule(10.0)
		g.DrawLandBoundaries()
		g.DrawCountryBoundaries()
		g.CenterOn(51.453349, -2.588323)
		return g.SavePNG(out, 400)
	},

}

func openWriter(out string) (io.WriteCloser, error) {
	if out == "" {
		return os.Stdout, nil
	}
	return os.Create(out)
}

func init() {
	RootCmd.AddCommand(locationsCmd)

	// Here you will define your flags and configuration settings.<commit_msg>add support for stdout wirting<commit_after>package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
	"os"

	"github.com/mmcloughlin/globe"
	"io"
	"image/png"
)

// locationsCmd represents the locations command
var locationsCmd = &cobra.Command{
	Use:   "locations",
	Short: "TODO",
	Long: `TODO
.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		out, err := cmd.Flags().GetString("output")
		if err != nil {
			return fmt.Errorf("cannot determine output: %s", err)
		}
		g := globe.New()
		g.DrawGraticule(10.0)
		g.DrawLandBoundaries()
		g.DrawCountryBoundaries()
		g.CenterOn(51.453349, -2.588323)
		writer, err := openWriter(out)
		if err != nil {
			return fmt.Errorf("cannot open output '%s': %s", out, err)
		}
		defer writer.Close()
		image := g.Image(400)
		return png.Encode(writer, image)
	},

}

func openWriter(out string) (io.WriteCloser, error) {
	if out == "" {
		return os.Stdout, nil
	}
	return os.Create(out)
}

func init() {
	RootCmd.AddCommand(locationsCmd)

	// Here you will define your flags and configuration settings.
{'fraction_non_alphanumeric': 0.15239096163951654, 'fraction_numerical': 0.02417235943247504, 'mean_word_length': 3.857142857142857, 'pattern_counts': {'":': 0, '<': 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': '3987985', 'n_tokens_mistral': 788, 'n_tokens_neox': 720, 'n_words': 170}