Skip to content

Commit 9b67b17

Browse files
committed
Remove --base-config flag from program utility
1 parent 2ab1cdc commit 9b67b17

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## unreleased
2+
3+
* *(util.program)* Removed `--base-config` flag in bridges, as there are no
4+
valid use cases (package data should always work) and it's easy to cause
5+
issues by pointing the flag at the wrong file.
6+
17
## v0.20.0 (2023-06-25)
28

39
* Dropped Python 3.8 support.

mautrix/util/program.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def preinit(self) -> None:
119119
self.check_config()
120120

121121
@property
122-
def _default_base_config(self) -> str:
122+
def base_config_path(self) -> str:
123123
return f"pkg://{self.module}/example-config.yaml"
124124

125125
def prepare_arg_parser(self) -> None:
@@ -133,35 +133,24 @@ def prepare_arg_parser(self) -> None:
133133
metavar="<path>",
134134
help="the path to your config file",
135135
)
136-
self.parser.add_argument(
137-
"-b",
138-
"--base-config",
139-
type=str,
140-
default=self._default_base_config,
141-
metavar="<path>",
142-
help="the path to the example config (for automatic config updates)",
143-
)
144136
self.parser.add_argument(
145137
"-n", "--no-update", action="store_true", help="Don't save updated config to disk"
146138
)
147139

148140
def prepare_config(self) -> None:
149141
"""Pre-init lifecycle method. Extend this if you want to customize config loading."""
150-
self.config = self.config_class(self.args.config, self.args.base_config)
142+
self.config = self.config_class(self.args.config, self.base_config_path)
151143
self.load_and_update_config()
152144

153145
def load_and_update_config(self) -> None:
154146
self.config.load()
155147
try:
156148
self.config.update(save=not self.args.no_update)
157149
except BaseMissingError:
158-
if self.args.base_config != self._default_base_config:
159-
print(f"Failed to read base config from {self.args.base_config}")
160-
else:
161-
print(
162-
"Failed to read base config from the default path "
163-
f"({self._default_base_config}). Maybe your installation is corrupted?"
164-
)
150+
print(
151+
"Failed to read base config from the default path "
152+
f"({self.base_config_path}). Maybe your installation is corrupted?"
153+
)
165154
sys.exit(12)
166155

167156
def check_config(self) -> None:

0 commit comments

Comments
 (0)