Skip to content

Commit c2fd4df

Browse files
committed
docs: document user configuration file feature
Add documentation for: - --config CLI option in Common options section - Configuration File section with locations, format, and examples - Configuration precedence order - Path expansion for home directory (~/) - Examples showing various usage patterns
1 parent 437bdab commit c2fd4df

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ Commands:
210210
These options are supported by all commands:
211211
212212
```
213+
--config=<configFile>
214+
Path to user configuration file (default: JPM_CONFIG
215+
environment variable, ~/.config/jpm/config.yml, or
216+
~/.jpmcfg.yml)
213217
-c, --cache=<cacheDir>
214218
Directory where downloaded artifacts will be cached
215219
(default: value of JPM_CACHE environment variable;
@@ -535,6 +539,49 @@ actions:
535539
clean: "rm -f *.class"
536540
```
537541
542+
## Configuration File
543+
544+
`jpm` supports user-level configuration files to set default values for common command-line options. This allows you to configure preferences once instead of passing the same options repeatedly.
545+
546+
### Configuration File Locations
547+
548+
Configuration files are searched in the following order:
549+
550+
1. **Explicit path** - Specified via `--config` option or `JPM_CONFIG` environment variable
551+
2. **`~/.config/jpm/config.yml`** - XDG Base Directory standard location (primary)
552+
3. **`~/.jpmcfg.yml`** - Fallback location (home directory)
553+
554+
The first file found is used. If no configuration file exists, jpm uses built-in defaults.
555+
556+
### Configuration File Format
557+
558+
```yaml
559+
config:
560+
cache: ~/my-jpm-cache
561+
directory: libs
562+
no-links: false
563+
repositories:
564+
myrepo: https://my.repo.com/maven2
565+
private: https://private.repo.com/releases
566+
```
567+
568+
### Configuration Options
569+
570+
- **`cache`** - Directory for caching downloaded artifacts (equivalent to `--cache` option)
571+
- **`directory`** - Default directory to copy artifacts to (equivalent to `--directory` option)
572+
- **`no-links`** - Whether to copy files instead of creating symlinks (equivalent to `--no-links` option)
573+
- **`repositories`** - Map of repository names to URLs (merged with `--repo` options)
574+
575+
### Path Expansion
576+
577+
Paths in the configuration file support home directory expansion:
578+
579+
```yaml
580+
config:
581+
cache: ~/jpm-cache # Expands to /home/user/jpm-cache
582+
directory: ~/.local/lib/jpm # Expands to /home/user/.local/lib/jpm
583+
```
584+
538585
## Development
539586
540587
To build the project simply run:

0 commit comments

Comments
 (0)