Skip to content

Commit 80fe7ef

Browse files
committed
Added explicit environment variable declarations
1 parent 2b3b358 commit 80fe7ef

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

bumpversion/cli.py

+29-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"--config-file",
3434
metavar="FILE",
3535
required=False,
36+
envvar="BUMPVERSION_CONFIG_FILE",
3637
type=click.Path(exists=True),
3738
help="Config file to read most of the variables from.",
3839
)
@@ -41,54 +42,63 @@
4142
"--verbose",
4243
count=True,
4344
required=False,
44-
help="Print verbose logging to stderr",
45+
envvar="BUMPVERSION_VERBOSE",
46+
help="Print verbose logging to stderr. Can specify several times for more verbosity.",
4547
)
4648
@click.option(
4749
"--allow-dirty/--no-allow-dirty",
4850
default=None,
4951
required=False,
52+
envvar="BUMPVERSION_ALLOW_DIRTY",
5053
help="Don't abort if working directory is dirty, or explicitly abort if dirty.",
5154
)
5255
@click.option(
5356
"--current-version",
5457
metavar="VERSION",
5558
required=False,
59+
envvar="BUMPVERSION_CURRENT_VERSION",
5660
help="Version that needs to be updated",
5761
)
5862
@click.option(
5963
"--new-version",
6064
metavar="VERSION",
6165
required=False,
66+
envvar="BUMPVERSION_NEW_VERSION",
6267
help="New version that should be in the files",
6368
)
6469
@click.option(
6570
"--parse",
6671
metavar="REGEX",
6772
required=False,
73+
envvar="BUMPVERSION_PARSE",
6874
help="Regex parsing the version string",
6975
)
7076
@click.option(
7177
"--serialize",
7278
metavar="FORMAT",
7379
multiple=True,
7480
required=False,
81+
envvar="BUMPVERSION_SERIALIZE",
7582
help="How to format what is parsed back to a version",
7683
)
7784
@click.option(
7885
"--search",
7986
metavar="SEARCH",
8087
required=False,
88+
envvar="BUMPVERSION_SEARCH",
8189
help="Template for complete string to search",
8290
)
8391
@click.option(
8492
"--replace",
8593
metavar="REPLACE",
8694
required=False,
95+
envvar="BUMPVERSION_REPLACE",
8796
help="Template for complete string to replace",
8897
)
8998
@click.option(
9099
"--no-configured-files",
91100
is_flag=True,
101+
envvar="BUMPVERSION_NO_CONFIGURED_FILES",
92102
help=(
93103
"Only replace the version in files specified on the command line, "
94104
"ignoring the files from the configuration file."
@@ -98,46 +108,54 @@
98108
"--dry-run",
99109
"-n",
100110
is_flag=True,
111+
envvar="BUMPVERSION_DRY_RUN",
101112
help="Don't write any files, just pretend.",
102113
)
103114
@click.option(
104115
"--commit/--no-commit",
105116
default=None,
117+
envvar="BUMPVERSION_COMMIT",
106118
help="Commit to version control",
107119
)
108120
@click.option(
109121
"--tag/--no-tag",
110122
default=None,
123+
envvar="BUMPVERSION_TAG",
111124
help="Create a tag in version control",
112125
)
113126
@click.option(
114127
"--sign-tags/--no-sign-tags",
115128
default=None,
129+
envvar="BUMPVERSION_SIGN_TAGS",
116130
help="Sign tags if created",
117131
)
118132
@click.option(
119133
"--tag-name",
120134
metavar="TAG_NAME",
121135
required=False,
136+
envvar="BUMPVERSION_TAG_NAME",
122137
help="Tag name (only works with --tag)",
123138
)
124139
@click.option(
125140
"--tag-message",
126141
metavar="TAG_MESSAGE",
127142
required=False,
143+
envvar="BUMPVERSION_TAG_MESSAGE",
128144
help="Tag message",
129145
)
130146
@click.option(
131147
"-m",
132148
"--message",
133149
metavar="COMMIT_MSG",
134150
required=False,
151+
envvar="BUMPVERSION_MESSAGE",
135152
help="Commit message",
136153
)
137154
@click.option(
138155
"--commit-args",
139156
metavar="COMMIT_ARGS",
140157
required=False,
158+
envvar="BUMPVERSION_COMMIT_ARGS",
141159
help="Extra arguments to commit command",
142160
)
143161
@click.option(
@@ -169,7 +187,16 @@ def cli(
169187
commit_args: Optional[str],
170188
show_list: bool,
171189
) -> None:
172-
"""Change the version."""
190+
"""
191+
Change the version.
192+
193+
VERSION_PART is the part of the version to increase, e.g. `minor` .
194+
Valid values include those given in the `--serialize` / `--parse` option.
195+
196+
FILES are additional file(s) to modify.
197+
If you want to rewrite only files specified on the command line, use with the
198+
`--no-configured-files` option.
199+
"""
173200
setup_logging(verbose)
174201

175202
logger.info("Starting BumpVersion %s", __version__)

bumpversion/config.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Config:
6868
def add_files(self, filename: Union[str, List[str]]) -> None:
6969
"""Add a filename to the list of files."""
7070
filenames = [filename] if isinstance(filename, str) else filename
71-
self.files.extend([FileConfig(filename=name) for name in filenames])
71+
self.files.extend([FileConfig(filename=name) for name in filenames]) # type: ignore[call-arg]
7272

7373
@property
7474
def version_config(self) -> "VersionConfig":
@@ -99,6 +99,7 @@ def version_config(self) -> "VersionConfig":
9999

100100
CONFIG_FILE_SEARCH_ORDER = (
101101
Path(".bumpversion.cfg"),
102+
Path(".bumpversion.toml"),
102103
Path("setup.cfg"),
103104
Path("pyproject.toml"),
104105
)
@@ -148,7 +149,8 @@ def get_all_part_configs(config_dict: dict) -> Dict[str, VersionPartConfig]:
148149
parts = config_dict["parts"]
149150
all_labels = set(itertools.chain.from_iterable([labels_for_format(fmt) for fmt in serialize]))
150151
return {
151-
label: VersionPartConfig(**parts[label]) if label in parts else VersionPartConfig() for label in all_labels
152+
label: VersionPartConfig(**parts[label]) if label in parts else VersionPartConfig() # type: ignore[call-arg]
153+
for label in all_labels
152154
}
153155

154156

0 commit comments

Comments
 (0)