Skip to main content

The settingspec cover

SettingSpec Check Crates.io Version PyPI Version NPM Version

SettingSpec

  1. Concepts
    1. Single file convenience
    2. Declarative profiles as environments
    3. Language independent
    4. Easy secrets
      1. SecretSpec
      2. Dotenv
      3. Cottage or agebox
  2. Learn more

Concepts

Single file convenience

With a single source of truth, i.e., settingspec.toml, you don't need to mentally merge settings from multiple files, say common.toml, dev.toml, prod.toml, etc. No surprise overwrites. One file for all environments, all languages, all submodules.

Declarative profiles as environments

[spec]                               # Optional: Declare the specification here
profile.key = "SETTINGSPEC_PROFILE"  # Default: Environment variable name to switch between profiles
profile.options = [                  # Optional: Enables strict checking of per-profile declarations
  "dev",
  "stage",
  "prod",
]
profile.default = "dev"  # Optional: Default profile when the switch is not set

[settings]                 # Declare the settings here with syntax: `<key>.<profile>.<directive> = <value>`
key1.default.val = "val1"  # Default value for all profiles
key1.prod.val = "prod1"    # Override the default value when SETTINGSPEC_PROFILE=prod

# Strictly define different values for different profiles
key2.dev.val = "dev2"      # When SETTINGSPEC_PROFILE=dev, key2=dev2
key2.stage.val = "stage2"
key2.prod.val = "prod2"

Overrides are intentional and kept in plain sight (see key1).

By not defining a default value, you can ensure that you never miss adding a value for a specific profile (e.g. this file will refuse to load if key2.prod declaration is missing).

Language independent

The command-line tool settingspec can export the final settings into well-known formats such as toml, json, yaml, etc., or hard-coded modules such as .py, .js, .lua, etc., write them to disk, print, or pipe them via stdin or even export as environment variables, allowing you to use a single settingspec.toml without worrying about the target language.

[spec]
export.file = true  # Default: Export all settings into settings.toml
# export.file = {   # Optional: Fine-grained control over what to export
#   "settings.json" = true,
#   "settings.yaml" = {
#     key1 = true,
#     group1 = true,
#     group2.subgroup = true,
#     group3.subgroup.key1 = false,
#     "#tag1" = true,
#   },
# }
export.skip_gitignore = false  # Default: Auto-append exported files to .gitignore if inside a git repo
export.mode = 0x600     # Default: File permission mode for the exported files
export.keep = false     # Default: Cleanup the exported files after the program exits
export.stdout = "toml"  # Optional: Print in toml format
export.env = "PREFIX_"  # Optional: Export as environment variables prefixed with this string
export.stdin = "toml"   # Optional: Pass settings to program stdin in specified format

[settings]
key1.default.val = "val1"
group1.key1.default.val = "group1val1"
group2.subgroup.key1.default.val = "group2val1"
group3.subgroup.key1.default.val = "group3val1"
group3.subgroup.key1.default.tags = ["tag1", "tag2"]

Now export the final settings as declared.

settingspec export

Or keep watching to export when settingspec.toml changes.

settingspec watch

Or directly run the program with exported settings.

settingspec run -- [your program]...

If no export option is specified, the default behavior is to export all settings into settings.toml.

Easy secrets

Unlike regular settings, secrets aren't supposed to be easily visible. So, they are best declared inside hidden/encrypted files and passed via environment variables or via stdin.

However, with SettingSpec, we can ensure that they are actually set and also include them in the final exported settings.

SecretSpec

You can pair up SettingSpec with a declarative secrets manager such as SecretSpec.

secretspec.toml

[project]
name = "my-app"
revision = "1.0"

[profiles.default]
SECRET1 = { description = "Secret One", required = true }
SECRET2 = { description = "Secret Two", required = false }

settingspec.toml

[spec]
profile.options = ["dev", "stage", "prod"]

[settings]
secret1.default.env = "SECRET1"  # Load value from $SECRET1

# Override the default value from environment variables
secret2.default.val = "defaultvalue"  # Default value if $SECRET2 is not set
secret2.default.env = "SECRET2"       # Load value from $SECRET2 if set
secret2.prod.env = "PRODSECRET"       # Load value from $PRODSECRET if SETTINGSPEC_PROFILE=prod

With these set up, run:

secretspec run -- settingspec run -- [your program]...

Dotenv

Or keep things simple with Dotenv.

[spec]
profile.options = ["dev", "stage", "prod"]

envfile.default = ".env"    # Default environment file
envfile.stage = ".env.age"  # Also supports age-encrypted env files
envfile.prod = "-"          # Read from stdin, encrypted or not

# decryption.key.env = "SETTINGSPEC_DECRYPTION_KEY"  # Default
# decryption.key.path = "~/.ssh/"                    # Default

[settings]
secret1.default.env = "SECRET1"     # Load value from $SECRET1

Cottage or agebox

Too simple? Use Cottage or agebox.

[spec]
envfile.default = ".env.cott.age"

# decryption.key.env = "AGEBOX_PRIVATE_KEYS"
# decryption.key.env = "COTTAGE_IDENTITY"
decryption.key.path = "~/.config/cottage/identity:~/.ssh"

[settings]
secret.default.env = "SECRET"

Learn more

Check out the settingspec.toml example file and full specification for more details.

Metadata

Release files for settingspec 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for settingspec 0.5.1
File Size Uploaded
settingspec-0.5.1.tar.gz 44.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for settingspec 0.5.1
File
settingspec-0.5.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
settingspec-0.5.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
settingspec-0.5.1-py3-none-win32.whl Python 3 none Windows x86-32 Details
settingspec-0.5.1-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
settingspec-0.5.1-py3-none-musllinux_1_2_i686.whl Python 3 none Linux musl 1.2+ x86-32 Details
settingspec-0.5.1-py3-none-musllinux_1_2_armv7l.whl Python 3 none Linux musl 1.2+ ARMv7l Details
settingspec-0.5.1-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
settingspec-0.5.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
settingspec-0.5.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl Python 3 none Linux glibc 2.17+ IBM System/390x Details
settingspec-0.5.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl Python 3 none Linux glibc 2.17+ PowerPC 64-le Details
settingspec-0.5.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl Python 3 none Linux glibc 2.17+ x86-32 Details
settingspec-0.5.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details
settingspec-0.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
settingspec-0.5.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
settingspec-0.5.1-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 14.9 MB

Release files / settingspec-0.5.1.tar.gz

Download URL settingspec-0.5.1.tar.gz
Size 44.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9b1f2f7c34ec0121fa63cbee5d32c0f87623f4dab4b5aca3ab2cc57897380a55
BLAKE2b-256 checksum
How to use checksums
943ad4a84eef52fec79315776ee499395f261869a779c9861ba8db8d3a59e043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-win_arm64.whl

Download URL settingspec-0.5.1-py3-none-win_arm64.whl
Size 850.8 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
8635d13d07f139a07917ff932e8a0233f984c20a0ed9be25a5a2f628de93be27
BLAKE2b-256 checksum
How to use checksums
0b966cf4b660cd9627d3dd9edaa837eabb818a2721b0930423fc0388a5a9eefe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-win_amd64.whl

Download URL settingspec-0.5.1-py3-none-win_amd64.whl
Size 915.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
f28a258d149b697671a7cd2727a71080d7a6a2104769a259d6baad47101637d3
BLAKE2b-256 checksum
How to use checksums
79975077885228511556eaa9d90549e6a5ed76f7b70c112e2fade4535b8502b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-win32.whl

Download URL settingspec-0.5.1-py3-none-win32.whl
Size 888.1 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
5e9654469fe357ce4d02e6e211a6fe743c74f06c7dad0a940b7412f81b10d7a2
BLAKE2b-256 checksum
How to use checksums
b23cc6166a1db36d1c72ed38d3df27ba9a8d9da3095f39fc97b1ee3b378f3228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-musllinux_1_2_x86_64.whl

Download URL settingspec-0.5.1-py3-none-musllinux_1_2_x86_64.whl
Size 1.1 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c8ab847fbfabce15dfc55334c64dd9ac3765ccb61f413e6cc331293bd4572453
BLAKE2b-256 checksum
How to use checksums
d081c395fa3e1069ef875ab17cd0f0e3f9b8a67e1b6a3a22028179e4e85dcb20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-musllinux_1_2_i686.whl

Download URL settingspec-0.5.1-py3-none-musllinux_1_2_i686.whl
Size 1.1 MB
Tags Linux musl 1.2+ x86-32 Python 3
SHA-256 checksum
How to use checksums
75b647a9aad519734dc6f92046abd88c8cb93a77d215166e5f8cab9ea5ade166
BLAKE2b-256 checksum
How to use checksums
c540a4cbc05a14254bd1297606842438b43ab0505c1fe62be563ff3b87bc9c3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-musllinux_1_2_armv7l.whl

Download URL settingspec-0.5.1-py3-none-musllinux_1_2_armv7l.whl
Size 1.0 MB
Tags Linux musl 1.2+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
65d46dd3937ff9a5cbbd32995dbb5e9a4f015999c2878785e1d9d44bd0076179
BLAKE2b-256 checksum
How to use checksums
a7ab8ec0b3942df7f3a550704783578fcd96c7719d55a64ed9291d3a82b21361
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-musllinux_1_2_aarch64.whl

Download URL settingspec-0.5.1-py3-none-musllinux_1_2_aarch64.whl
Size 987.1 kB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
de22aca5767fb86ff898958327d923aab770a7937d21ee2cd4f4eb915873684f
BLAKE2b-256 checksum
How to use checksums
a6b6e21eadf85f49056490ce9a8bc6fda92b1f328b1132585c4091384e6a2d21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL settingspec-0.5.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.0 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
26f64dc59072e0ad87b87b48f027bb8cffb768cf4c911c7a2eeb50716e1e1efa
BLAKE2b-256 checksum
How to use checksums
3fb77b6fc0c3f9d3879a8705607df87668a0476faebb1528afc655379e7561f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL settingspec-0.5.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 1.1 MB
Tags Linux glibc 2.17+ IBM System/390x Python 3
SHA-256 checksum
How to use checksums
86346126055c4e9ce0f445ffa7aa4582991d9756138d96d7b12a094ddeec9ed5
BLAKE2b-256 checksum
How to use checksums
56b51b2c87dcf38bd4105e17859b4afd2bb0604a91834ccd1869b5c117d4494b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL settingspec-0.5.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 1.1 MB
Tags Linux glibc 2.17+ PowerPC 64-le Python 3
SHA-256 checksum
How to use checksums
a2286777b0b6d8a00c2639c57808b1fe84efb59fd8fe4057618570bf549ed6de
BLAKE2b-256 checksum
How to use checksums
47f405d5257c3e95240ade16f8c725c85a7d003524a9728f6193681d7155df73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL settingspec-0.5.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Size 1.1 MB
Tags Linux glibc 2.17+ x86-32 Python 3
SHA-256 checksum
How to use checksums
46739be4309e2733ea9a137262a47ababcb434801bbdd1171275527f03b19054
BLAKE2b-256 checksum
How to use checksums
ce166c8bcfef6d4d9159358d7c7c3e0e8adad073e5f321d161aa8a2fd0f9f2aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL settingspec-0.5.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 988.8 kB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
a8dd502ac97b314557e75a2337ec5a94796f9ab740cd3904759a50a5c337dec2
BLAKE2b-256 checksum
How to use checksums
f3ea0740a1ab23dd98cef144cf505df4cd5f1131fb8fa292dd4e53955d3452a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL settingspec-0.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 941.3 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
99a834aaa06f09a5b78649434103af6925ad92b6c56cb4fd90fc7f1f3465c2a5
BLAKE2b-256 checksum
How to use checksums
ec4d96a3f34c7241ba1bc14e0aa0898ff132251249cef65bc5f3cbe25dabaa31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-macosx_11_0_arm64.whl

Download URL settingspec-0.5.1-py3-none-macosx_11_0_arm64.whl
Size 884.1 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
82a1844685c9153d5276f0fa04f4b5f72afcb3ebd76ae359204b26516a55056f
BLAKE2b-256 checksum
How to use checksums
49d9b432ec251eaa57ee0dfa9640bae2dda4946a203feddfc5b0bc9930416e54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / settingspec-0.5.1-py3-none-macosx_10_12_x86_64.whl

Download URL settingspec-0.5.1-py3-none-macosx_10_12_x86_64.whl
Size 974.9 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
617a6078966d25d1d8f0cf1c808d92c167c2f773589f6d6444a657c431b68012
BLAKE2b-256 checksum
How to use checksums
9c3a5bc98b838173060320763c6a864a7e13121337851f2000421fc5c7f267ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.7.0

16 release files

0.6.0

16 release files

This release

0.5.1 This release

16 release files

0.5.0

16 release files

0.4.0

16 release files

0.3.0

16 release files

0.2.0

16 release files

0.1.2

16 release files

0.1.1

16 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page