| 85 | } |
| 86 | |
| 87 | func (l *Flags) URI() (*storage.URI, error) { |
| 88 | db := strings.TrimRight(l.DB, "/") |
| 89 | if !l.dbSpecified { |
| 90 | db = getDefaultDataDir() |
| 91 | } |
| 92 | if db == "" { |
| 93 | return nil, errors.New("database location must be set (either with the -db flag or SUPER_DB environment variable)") |
| 94 | } |
| 95 | u, err := storage.ParseURI(db) |
| 96 | if err != nil { |
| 97 | err = fmt.Errorf("error parsing database location: %w", err) |
| 98 | } |
| 99 | return u, err |
| 100 | } |
| 101 | |
| 102 | // ClientURI returns the URI of the database to connect to. If the database path is |
| 103 | // the defaultDataDir, it first checks if a SuperDB service is running on |