func getRepoPath(req cmds.Request) (string, error) { repoOpt, found, err := req.Option("config").String() if err != nil { return "", err } if found && repoOpt != "" { return repoOpt, nil } repoPath, err := fsrepo.BestKnownPath() if err != nil { return "", err } return repoPath, nil }
func main() { flag.Parse() // precedence // 1. --repo flag // 2. IPFS_PATH environment variable // 3. default repo path var ipfsPath string if *repoPath != "" { ipfsPath = *repoPath } else { var err error ipfsPath, err = fsrepo.BestKnownPath() if err != nil { log.Fatal(err) } } if err := run(ipfsPath, *watchPath); err != nil { log.Fatal(err) } }