Beispiel #1
0
// setup configuration options
func init() {
	var err error
	if currentUser, err = user.Current(); err != nil {
		log.Fatal(err)
	}

	configo.StringVar(&spoolPath, "spooldir", filepath.Join(currentUser.HomeDir, "spool"), "The directory to look in for new pictures to spool.")
	configo.StringVar(&basePhotoPath, "photodir", filepath.Join(currentUser.HomeDir, "Pictures"), "The directory that new pictures will be copied to as they are spooled.")
	configo.StringVar(&errorPath, "errordir", filepath.Join(currentUser.HomeDir, "spool_error"), "The directory to copy pictures to when an error occurs.")
	configo.StringVar(&md5DbPath, "dbdir", filepath.Join(currentUser.HomeDir, ".photo-spool.db"), "The full path to the photo database file.")
	configo.BoolFlagVar(&noop, "dryrun", false, "If set the program has no effect but prints what would have happened.")

	if err = configo.Parse(); err != nil {
		panic(err)
	}

	if err := os.MkdirAll(errorPath, 0775); err != nil {
		log.Fatal(err)
	}

	if err := os.MkdirAll(basePhotoPath, 0775); err != nil {
		log.Fatal(err)
	}

	if err := os.MkdirAll(spoolPath, 0775); err != nil {
		log.Fatal(err)
	}

	if spool, err = spooler.New(md5DbPath, basePhotoPath, errorPath, noop); err != nil {
		log.Fatalf("Could not create a new Spool. %v\n", err)
	}
}
Beispiel #2
0
func main() {
	if err := configo.Parse(); err != nil {
		panic(err)
	}

	fmt.Printf("species      = %s\n", *species)
	fmt.Printf("gopherType   = %s\n", gopherType)
	fmt.Printf("intervalFlag = %s\n", intervalFlag)
	fmt.Printf("alive        = %v\n", aliveFlag)
	fmt.Printf("furry        = %v\n", furryConfig)
}