Exemplo n.º 1
0
var remoteIdQuestion = &question{
	"remote_id",
	"Remote folder ID to sync with, L for list.",
	"root",
}

var authorizationCodeQuestion = &question{
	"auth_code",
	"OAuth 2.0 authorization code.",
	"",
}

var localPathQuestion = &question{
	"local_path",
	"Local path to sync from.",
	config.DefaultMountpoint(),
}

type question struct {
	Name    string
	Usage   string
	Default string
}

func readQuestion(opt *question) string {
	var s string
	for s == "" {
		fmt.Printf("%v %v [default=%v]>> ", opt.Usage, Bold(opt.Name), Blue(opt.Default))
		_, err := fmt.Scanln(&s)
		if err != nil && err.Error() != "unexpected newline" {
			logger.F("Bad scan.", err)
Exemplo n.º 2
0
	"github.com/odeke-em/drivefuse/auth"
	"github.com/odeke-em/drivefuse/blob"
	"github.com/odeke-em/drivefuse/cmd"
	"github.com/odeke-em/drivefuse/config"
	"github.com/odeke-em/drivefuse/logger"
	"github.com/odeke-em/drivefuse/metadata"
	"github.com/odeke-em/drivefuse/mount"
	"github.com/odeke-em/drivefuse/syncer"

	client "github.com/google/google-api-go-client/drive/v2"
)

var (
	flagDataDir    = flag.String("datadir", config.DefaultDataDir(), "path of the data directory")
	flagMountPoint = flag.String("mountpoint", config.DefaultMountpoint(), "mount point")
	flagBlockSync  = flag.Bool("blocksync", false, "set true to force blocking sync on startup")

	flagRunAuthWizard = flag.Bool("wizard", false, "Run the startup wizard.")

	metaService  *metadata.MetaService
	driveService *client.Service
	blobManager  *blob.Manager
)

func main() {
	flag.Parse()
	// add a lock to the config dir, no two instances should
	// run at the same time
	cfg := config.NewConfig(*flagDataDir)
	err := cfg.Setup()