<commit_before>package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	if len(os.Args) < 2 {
		doLs(".")
	}

	for _, path := range os.Args {
		doLs(path)
	}
}

func doLs(path string) {
	fis, err := ioutil.ReadDir(path)
	if err != nil {
		perror(err)
		return
	}

	for _, fi := range fis {
		fmt.Printf("%s\n", fi.Name())
	}
}

func perror(err error) {
	fmt.Fprintf(os.Stderr, "[error] %v\n", err)
}<commit_msg>ls.go: add flags -A and -R<commit_after>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

const (
	unixHiddenFilePrefix = "."
	currentDir           = "."
)

type option struct {
	all bool
	rec bool
}

func newOption() option {
	opt := option{}

	flag.BoolVar(&opt.all, "A", false, "list all entries except for . and ..")
	flag.BoolVar(&opt.rec, "R", false, "recursively list subdirectories encountered")

	flag.Parse()

	return opt
}

func main() {
	opt := newOption()

	paths := flag.Args()
	if len(paths) == 0 {
		paths = []string{currentDir}
	}

	for _, path := range paths {
		doLs(path, opt)
	}
}

func doLs(path string, opt option) {
	fis, err := ioutil.ReadDir(path)
	if err != nil {
		perror(err)
		return
	}

	for _, fi := range fis {
		name := fi.Name()

		// skip the following process if not to display hidden files
		skip := !opt.all && isHidden(name)
		if skip {
			continue
		}

		fmt.Println(name)

		// run recursively
		isRec := opt.rec && fi.IsDir()
		if isRec {
			name = path + "/" + name
			doLs(name, opt)
		}
	}
}

func isHidden(path string) bool {
	return strings.HasPrefix(path, unixHiddenFilePrefix)
}

func perror(err error) {
	fmt.Fprintf(os.Stderr, "[error] %v\n", err)
}
{'fraction_non_alphanumeric': 0.16555082166768106, 'fraction_numerical': 0.0012172854534388314, 'mean_word_length': 3.0492610837438425, 'pattern_counts': {'":': 0, '<': 4, '<?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': '1604703', 'n_tokens_mistral': 707, 'n_tokens_neox': 665, 'n_words': 167}