Skip to content

Commit

Permalink
Merge pull request #49 from visr/patch-1
Browse files Browse the repository at this point in the history
README: show how to export prefs
  • Loading branch information
staticfloat authored Nov 11, 2023
2 parents 281b5f4 + 4ea3773 commit ae3184a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
The `Preferences` package provides a convenient, integrated way for packages to store configuration switches to persistent TOML files, and use those pieces of information at both run time and compile time in Julia v1.6+.
This enables the user to modify the behavior of a package, and have that choice reflected in everything from run time algorithm choice to code generation at compile time.
Preferences are stored as TOML dictionaries and are, by default, stored within a `(Julia)LocalPreferences.toml` file next to the currently-active project.
If a preference is "exported", it is instead stored within the `(Julia)Project.toml`.
If a preference is "exported" (`export_prefs=true`), it is instead stored within the `(Julia)Project.toml`.
The intention is to allow shared projects to contain shared preferences, while allowing for users themselves to override those preferences with their own settings in the `LocalPreferences.toml` file, which should be `.gitignore`d as the name implies.

Preferences can be set with depot-wide defaults; if package `Foo` is installed within your global environment and it has preferences set, these preferences will apply as long as your global environment is part of your [`LOAD_PATH`](https://docs.julialang.org/en/v1/manual/code-loading/#Environment-stacks).
Expand All @@ -29,7 +29,7 @@ Preferences use is very simple; it is all based around four functions (which eac

* `@load_preference(key, default = nothing)`: This loads a preference named `key` for the current package. If no such preference is found, it returns `default`.

* `@set_preferences!(pairs...)`: This allows setting multiple preferences at once as pairs.
* `@set_preferences!(pairs...; export_prefs=false)`: This allows setting multiple preferences at once as pairs.

* `@has_preference(key)`: Returns true if the preference named `key` is found, and `false` otherwise.

Expand Down

0 comments on commit ae3184a

Please sign in to comment.