Adding command line interface

This commit is contained in:
Alex Yatskov 2015-05-18 11:12:22 +09:00
parent 378154d5a3
commit 540445f661

33
vfs.go
View File

@ -25,28 +25,49 @@ package main
import ( import (
"bazil.org/fuse" "bazil.org/fuse"
"bazil.org/fuse/fs" "bazil.org/fuse/fs"
_ "bazil.org/fuse/fs/fstestutil"
"flag"
"fmt"
"log" "log"
"os"
) )
func usage() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] database mountpoint\n\n", os.Args[0])
fmt.Fprintf(os.Stderr, "Parameters:\n")
flag.PrintDefaults()
}
func main() { func main() {
db, err := newDatabase("fs") flag.Usage = usage
flag.Parse()
if flag.NArg() != 2 {
usage()
os.Exit(2)
}
database := flag.Arg(0)
mountpoint := flag.Arg(1)
db, err := newDatabase(database)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
c, err := fuse.Mount("mp") conn, err := fuse.Mount(mountpoint)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer c.Close() defer conn.Close()
err = fs.Serve(c, db) err = fs.Serve(conn, db)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
<-c.Ready <-conn.Ready
if err := c.MountError; err != nil { if err := conn.MountError; err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }