<commit_before>/**
 * cli.go - Process default environment values, log handling, version number
 * and uother common code blocks used to implement cli tools.
 */
package common

import (
	"flag"
	"fmt"
	"os"
	"path/filepath"
	"strconv"
	"strings"
)

const revision = "v0.0.4"

var CommandName = func(s string) string {
	return filepath.Base(s)
}

var Version = func() {
	fmt.Printf("%s version %s\n", os.Args[0], revision)
	os.Exit(0)
}

var Usage = func(exit_code int, body string, msg string) {
	var fh = os.Stderr
	if exit_code == 0 {
		fh = os.Stdout
	}
	fmt.Fprintf(fh, `%s
 USAGE %s [options]
 %s
 OPTIONS

`, msg, CommandName(os.Args[0]), body)

	flag.VisitAll(func(f *flag.Flag) {
		fmt.Fprintf(fh, "\t-%s\t(defaults to %s) %s\n", f.Name, f.DefValue, f.Usage)
	})

	fmt.Fprintf(fh, `
<commit_msg>updated revision with a -alpha suffix since I am workig on next branch<commit_after>/**
 * cli.go - Process default environment values, log handling, version number
 * and uother common code blocks used to implement cli tools.
 */
package common

import (
	"flag"
	"fmt"
	"os"
	"path/filepath"
	"strconv"
	"strings"
)

const revision = "v0.0.4-alpha"

var CommandName = func(s string) string {
	return filepath.Base(s)
}

var Version = func() {
	fmt.Printf("%s version %s\n", os.Args[0], revision)
	os.Exit(0)
}

var Usage = func(exit_code int, body string, msg string) {
	var fh = os.Stderr
	if exit_code == 0 {
		fh = os.Stdout
	}
	fmt.Fprintf(fh, `%s
 USAGE %s [options]
 %s
 OPTIONS

`, msg, CommandName(os.Args[0]), body)

	flag.VisitAll(func(f *flag.Flag) {
		fmt.Fprintf(fh, "\t-%s\t(defaults to %s) %s\n", f.Name, f.DefValue, f.Usage)
	})

	fmt.Fprintf(fh, `

{'fraction_non_alphanumeric': 0.15798922800718132, 'fraction_numerical': 0.008378216636744464, 'mean_word_length': 3.683473389355742, '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': '6223325', 'n_tokens_mistral': 687, 'n_tokens_neox': 664, 'n_words': 182}