tractor.dev/toolkit-go@v0.0.0-20241010005851-214d91207d07/engine/fs/fuser/cmd/fusedev/main.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"io"
     6  	"log"
     7  	"os"
     8  	"strings"
     9  
    10  	"github.com/hanwen/go-fuse/v2/fs"
    11  	"tractor.dev/toolkit-go/engine/fs/fuser"
    12  	"tractor.dev/toolkit-go/engine/fs/githubfs"
    13  )
    14  
    15  func main() {
    16  	debug := flag.Bool("debug", false, "print debug data")
    17  
    18  	flag.Parse()
    19  	if len(flag.Args()) < 2 {
    20  		log.Fatal("Usage:\n  fusedev [-debug] REPO MOUNTPOINT")
    21  	}
    22  
    23  	repo := strings.Split(flag.Arg(0), "/")
    24  	if len(repo) < 2 {
    25  		log.Fatal("Usage:\n  fusedev [-debug] PATH MOUNTPOINT")
    26  	}
    27  	// osfs := workingpathfs.New(osfs.New(), flag.Arg(0))
    28  	gfs := githubfs.New(repo[0], repo[1], os.Getenv("GH_TOKEN"))
    29  
    30  	opts := &fs.Options{}
    31  	//opts.Debug = *debug
    32  	if !*debug {
    33  		log.SetOutput(io.Discard)
    34  	}
    35  
    36  	server, err := fs.Mount(flag.Arg(1), &fuser.Node{FS: gfs}, opts)
    37  	if err != nil {
    38  		log.Fatalf("Mount fail: %v\n", err)
    39  	}
    40  
    41  	server.Wait()
    42  }