Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions docs/user/04-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,27 +504,14 @@ Environment variables use the prefix `DOT_` followed by the section-qualified ke
by single underscores, uppercased. For example `symlinks.mode` becomes `DOT_SYMLINKS_MODE`. There is
no double-underscore convention.

Only the following keys are bound:

```
DOT_DIRECTORIES_PACKAGE DOT_DIRECTORIES_TARGET DOT_DIRECTORIES_MANIFEST
DOT_LOGGING_LEVEL DOT_LOGGING_FORMAT DOT_LOGGING_DESTINATION DOT_LOGGING_FILE
DOT_SYMLINKS_MODE DOT_SYMLINKS_FOLDING DOT_SYMLINKS_OVERWRITE
DOT_SYMLINKS_BACKUP DOT_SYMLINKS_BACKUP_SUFFIX
DOT_IGNORE_USE_DEFAULTS DOT_IGNORE_PATTERNS DOT_IGNORE_OVERRIDES
DOT_IGNORE_PER_PACKAGE_IGNORE DOT_IGNORE_MAX_FILE_SIZE DOT_IGNORE_INTERACTIVE_LARGE_FILES
DOT_DOTFILE_TRANSLATE DOT_DOTFILE_PREFIX
DOT_OUTPUT_FORMAT DOT_OUTPUT_COLOR DOT_OUTPUT_PROGRESS
DOT_OUTPUT_VERBOSITY DOT_OUTPUT_WIDTH
DOT_OPERATIONS_DRY_RUN DOT_OPERATIONS_ATOMIC DOT_OPERATIONS_MAX_PARALLEL
DOT_PACKAGES_SORT_BY DOT_PACKAGES_AUTO_DISCOVER DOT_PACKAGES_VALIDATE_NAMES
DOT_DOCTOR_AUTO_FIX DOT_DOCTOR_CHECK_MANIFEST DOT_DOCTOR_CHECK_BROKEN_LINKS
DOT_DOCTOR_CHECK_ORPHANED DOT_DOCTOR_CHECK_PERMISSIONS
DOT_EXPERIMENTAL_PARALLEL DOT_EXPERIMENTAL_PROFILING
```

`symlinks.backup_dir`, `dotfile.package_name_mapping`, `output.table_style`, and every key under
`update` and `network` have no environment binding; set them in the configuration file.
Every configuration key in the tables above is bound: `DOT_` plus the uppercased key with `.`
replaced by `_`. `symlinks.backup_dir` becomes `DOT_SYMLINKS_BACKUP_DIR`,
`dotfile.package_name_mapping` becomes `DOT_DOTFILE_PACKAGE_NAME_MAPPING`, and the `update` and
`network` sections follow the same rule. An environment value overrides the configuration file even
when it sets a boolean to `false`.

Path-typed values (`directories.*`, `symlinks.backup_dir`, `logging.file`) expand `~` and `$VAR`
references exactly as file values do.

`DOT_CONFIG` is handled separately and overrides the configuration file path.

Expand Down
7 changes: 4 additions & 3 deletions docs/user/08-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ dot manage dot-vim # Uses config file
dot -v manage dot-vim # -v overrides config
```

Not every key is bound to an environment variable. `symlinks.backup_dir`,
`dotfile.package_name_mapping`, `output.table_style`, and the whole `update`
and `network` sections have no environment binding.
Every configuration key is bound to an environment variable: `DOT_` plus the
uppercased key with dots replaced by underscores, including `symlinks.backup_dir`,
`dotfile.package_name_mapping`, `output.table_style`, and the `update` and
`network` sections.

### Invalid Configuration

Expand Down
30 changes: 20 additions & 10 deletions internal/config/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ import (
// On error the configuration is left as written, and the message names both
// the offending key and the reference that could not be resolved.
func (c *ExtendedConfig) ExpandPaths() error {
fields := []struct {
key string
value *string
}{
{"directories.package", &c.Directories.Package},
{"directories.target", &c.Directories.Target},
{"directories.manifest", &c.Directories.Manifest},
{"symlinks.backup_dir", &c.Symlinks.BackupDir},
{"logging.file", &c.Logging.File},
}
fields := c.pathFields()

expanded := make([]string, len(fields))
for i, field := range fields {
Expand All @@ -62,6 +53,25 @@ func (c *ExtendedConfig) ExpandPaths() error {
return nil
}

// pathField pairs a path-typed configuration key with its value slot.
type pathField struct {
key string
value *string
}

// pathFields returns every path-typed configuration value in a stable order.
// It is the single list both ExpandPaths and the environment override path
// consume, so a new path-typed field is expanded everywhere or nowhere.
func (c *ExtendedConfig) pathFields() []pathField {
return []pathField{
{"directories.package", &c.Directories.Package},
{"directories.target", &c.Directories.Target},
{"directories.manifest", &c.Directories.Manifest},
{"symlinks.backup_dir", &c.Symlinks.BackupDir},
{"logging.file", &c.Logging.File},
}
}

// expandPath expands environment variables and a leading tilde in a single
// path value. An empty value stays empty, so callers can distinguish "unset"
// from "set to the home directory".
Expand Down
Loading
Loading