<commit_before>package main

import (
	"fmt"
	"os"
	"os/signal"
	"runtime"
	"sync"
	"syscall"

	"bazil.org/fuse"
	"bazil.org/fuse/fs"

	"github.com/jessevdk/go-flags"
)

var (
	version    = "compiled manually"
	compiledAt = "unknown"
)

// Options are global settings.
type Options struct {
	Seed    int  `long:"seed"                  description:"initial random seed"`
	Version bool `long:"version" short:"v"     description:"print version number"`

	mountpoint string
}

var opts = Options{}
var parser = flags.NewParser(&opts, flags.HelpFlag|flags.PassDoubleDash)

var exitRequested = make(chan struct{})

func init() {
	parser.Usage = "mountpoint"
	c := make(chan os.Signal)
	signal.Notify(c, syscall.SIGINT)

	go cleanupHandler(c)
}

func cleanupHandler(c <-chan os.Signal) {
	once := &sync.Once{}

	for range c {
		once.Do(func() {
			fmt.Println("Interrupt received, cleaning up")
			close(exitRequested)
		})
	}
}

func mount(opts Options) error {
	conn, err := fuse.Mount(
		opts.mountpoint,
		fuse.ReadOnly(),
		fuse.FSName("fakedatafs"),
	)
	if err != nil {
		return err
	}

	root := fs.Tree{}

	// root.Add("snapshots", fuse.NewSnapshotsDir(repo, cmd.Root))

	// cmd.global.Printf("Now serving %s at %s\n", repo.Backend().Location(), mountpoint)
	// cmd.global.Printf("Don't forget to umount after quitting!\n")

	// AddCleanupHandler(func() error {
	// 	return fuse.Unmount(mountpoint)
	// })

	// cmd.ready <- struct{}{}

	err = fs.Serve(conn, &root)
	if err != nil {
		return err
	}

	<-conn.Ready
	err = conn.MountError
	if err != nil {
		fmt.Fprintf(os.Stderr, "mount failed: %v\n", err)
		return fuse.Unmount(opts.mountpoint)
	}

	fmt.Printf("successfully mounted fakedatafs at %v\n", opts.mountpoint)

	<-exitRequested

	fmt.Printf("umounting...\n")
	return fuse.Unmount(opts.mountpoint)
}<commit_msg>Add FUSE scaffolding<commit_after>package main

import (
	"fmt"
	"os"
	"os/signal"
	"runtime"
	"sync"
	"syscall"

	"bazil.org/fuse"
	"bazil.org/fuse/fs"

	"github.com/jessevdk/go-flags"
)

var (
	version    = "compiled manually"
	compiledAt = "unknown"
)

// Options are global settings.
type Options struct {
	Seed    int  `long:"seed"                  description:"initial random seed"`
	Version bool `long:"version" short:"V"     description:"print version number"`
	Verbose bool `long:"verbose" short:"v"     description:"be verbose"`

	mountpoint string
}

var opts = Options{}
var parser = flags.NewParser(&opts, flags.HelpFlag|flags.PassDoubleDash)

var exitRequested = make(chan struct{})

func init() {
	parser.Usage = "mountpoint"
	c := make(chan os.Signal)
	signal.Notify(c, syscall.SIGINT)

	go cleanupHandler(c)
}

func cleanupHandler(c <-chan os.Signal) {
	once := &sync.Once{}

	for range c {
		once.Do(func() {
			fmt.Println("Interrupt received, cleaning up")
			close(exitRequested)
		})
	}
}

// V prints debug messages if verbose mode is requested.
func V(format string, data ...interface{}) {
	if opts.Verbose {
		fmt.Printf(format, data...)
	}
}

// M prints a message to stdout.
func M(format string, data ...interface{}) {
	fmt.Printf(format, data...)
}

func mount(opts Options) error {
	conn, err := fuse.Mount(
		opts.mountpoint,
		fuse.ReadOnly(),
		fuse.FSName("fakedatafs"),
	)
	if err != nil {
		return err
	}
	defer conn.Close()

	root := fs.Tree{}

	// root.Add("snapshots", fuse.NewSnapshotsDir(repo, cmd.Root))

	// cmd.global.Printf("Now serving %s at %s\n", repo.Backend().Location(), mountpoint)
	// cmd.global.Printf("Don't forget to umount after quitting!\n")

	// AddCleanupHandler(func() error {
	// 	return fuse.Unmount(mountpoint)
	// })

	// cmd.ready <- struct{}{}

	M("filesystem mounted at %v\n", opts.mountpoint)

	serveErrCh := make(chan error, 2)
	go func() {
		V("serving\n")
		err := fs.Serve(conn, &root)
		if err != nil {
			serveErrCh <- err
		}
		<-conn.Ready
		serveErrCh <- conn.MountError
	}()

	for {
		select {
		case err := <-serveErrCh:
			fmt.Fprintf(os.Stderr, "error: %v\n", err)
			return err
		case <-exitRequested:
			fmt.Printf("umounting...\n")
			return fuse.Unmount(opts.mountpoint)
		}
	}
}
{'fraction_non_alphanumeric': 0.16009791921664626, 'fraction_numerical': 0.0002447980416156671, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 14, '<?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': '774999', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1484, 'n_words': 343}