-
-
Notifications
You must be signed in to change notification settings - Fork 827
use jsonargparse #9413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThomasWaldmann
wants to merge
21
commits into
borgbackup:master
Choose a base branch
from
ThomasWaldmann:jsonargparse2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+782
−920
Open
use jsonargparse #9413
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
39636dc
make validators idempotent
ThomasWaldmann eabc473
streamline function names for borg key subcommands
ThomasWaldmann 7e4b753
refactor: separate pattern roots from positional paths
ThomasWaldmann c149a35
migrate to jsonargparse
ThomasWaldmann ad21207
fix make build_man / build_usage
ThomasWaldmann 68ebd68
SortBySpec: avoid triggering bandit security checker
ThomasWaldmann ec129ac
blacken src
ThomasWaldmann 4e6c16e
import from jsonargparse: SUPPRESS, REMAINDER, NameSpace
ThomasWaldmann dd9ee3d
adapt borg completion for jsonargparse
ThomasWaldmann 758c7b0
fix argparsing test
ThomasWaldmann 361ba01
reorg imports
ThomasWaldmann 15d5910
helpers.jap_helper -> helpers.argparsing
ThomasWaldmann c342c24
move compress.CompressionSpec to helpers.parseformat.CompressionSpec
ThomasWaldmann ad77c48
make build_usage / build_man: do not show options with SUPPRESS
ThomasWaldmann ceba422
reorg imports
ThomasWaldmann f951a12
add octal_int validator
ThomasWaldmann 52b994d
archiver: replace CommonOptions suffix hack with jsonargparse-native …
ThomasWaldmann 405d8ff
simplify flatten_namespace, add docstring for argparsing
ThomasWaldmann 8f51646
argparsing: add ArgumentParser subclass with borg's usual defaults
ThomasWaldmann fb6ce2d
add support for yaml config files, default config
ThomasWaldmann e4e484f
add support for auto-generated environment variables (jsonargparse)
ThomasWaldmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| Configuration files | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Borg supports reading options from YAML configuration files. This is | ||
| implemented via `jsonargparse <https://jsonargparse.readthedocs.io/>`_ | ||
| and works for all options that can also be set on the command line. | ||
|
|
||
| Default configuration file | ||
| ``$BORG_CONFIG_DIR/default.yaml`` is loaded automatically on every Borg | ||
| invocation if it exists. You do not need to pass ``--config`` explicitly | ||
| for this file. | ||
|
|
||
| ``--config PATH`` | ||
| Load additional options from the YAML file at *PATH*. | ||
| Options in this file take precedence over the default config file but are | ||
| overridden by explicit command-line arguments. This option can be used | ||
| multiple times, with later files overriding earlier ones. | ||
|
|
||
| ``--print_config`` | ||
| Print the current effective configuration (all options in YAML format) to | ||
| stdout and exit. This reflects the merged result of the default config | ||
| file, any ``--config`` file, environment variables, and command-line | ||
| arguments given before ``--print_config``. The output can be used as a | ||
| starting point for a config file. | ||
|
|
||
| File format | ||
| Config files are YAML documents. Top-level keys are option names | ||
| (without leading ``--`` and with ``-`` replaced by ``_``). | ||
| Nested keys correspond to subcommands. | ||
|
|
||
| Example ``default.yaml``:: | ||
|
|
||
| # apply to all borg commands: | ||
| log_level: info | ||
| show_rc: true | ||
|
|
||
| # options specific to "borg create": | ||
| create: | ||
| compression: zstd,3 | ||
| stats: true | ||
|
|
||
| The top-level keys set options that are common to all commands (equivalent | ||
| to placing them before the subcommand on the command line). Keys nested | ||
| under a subcommand name (e.g. ``create:``) are only applied when that | ||
| subcommand is invoked. | ||
|
|
||
| Precedence (lowest to highest) | ||
| 1. Default config file (``$BORG_CONFIG_DIR/default.yaml``) | ||
| 2. ``--config`` file(s) (in the order given) | ||
| 3. Environment variables (e.g. ``BORG_REPO``) | ||
| 4. Command-line arguments | ||
|
|
||
| .. note:: | ||
| ``--print_config`` shows the merged effective configuration and is a | ||
| convenient way to check what values Borg will actually use, and to | ||
| generate contents for your borg config file(s):: | ||
|
|
||
| borg --repo /backup/main create --compression zstd,3 --print_config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ pytest-cov==7.0.0 | |
| pytest-benchmark==5.2.3 | ||
| Cython==3.2.4 | ||
| pre-commit==4.5.1 | ||
| types-PyYAML==6.0.12.20250915 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,4 @@ pytest-benchmark | |
| Cython | ||
| pre-commit | ||
| bandit[toml] | ||
| types-PyYAML | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.