main: env variable for base directory

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-09-12 14:55:10 -04:00
parent d820978518
commit e3900382c7
Signed by: vbatts
GPG Key ID: 10937E57733F1362
1 changed files with 11 additions and 1 deletions

12
main.go
View File

@ -14,7 +14,9 @@ import (
)
var (
flVarBase = flag.String("b", filepath.Join(os.Getenv("HOME"), ".local/dedupe-linker/var"), "base directory where files are duplicated")
varBaseDir = filepath.Join(os.Getenv("HOME"), ".local/dedupe-linker/var")
flVarBase = flag.String("b", varBaseDir, "base directory where files are duplicated")
flCipher = flag.String("c", "sha1", "block cipher to use (sha1, or sha256)")
flWorkers = flag.Int("w", 2, "workers to do summing")
flNoop = flag.Bool("noop", false, "don't do any moving or linking")
@ -26,6 +28,10 @@ func init() {
if runtime.NumCPU() > 1 && len(os.Getenv("GOMAXPROCS")) == 0 {
runtime.GOMAXPROCS(2)
}
if os.Getenv("VARBASEDIR") != "" {
varBaseDir = filepath.Clean(os.Getenv("VARBASEDIR"))
}
}
func main() {
@ -35,6 +41,10 @@ func main() {
os.Setenv("DEBUG", "1")
}
if os.Getenv("DEBUG") != "" {
fmt.Fprintf(os.Stderr, "VARBASEDIR=%q\n", *flVarBase)
}
// TODO the *flCipher has not been checked yet, and would cause the directory to get created
ourbase, err := base.NewBase(*flVarBase, *flCipher)
if err != nil {