Skip to content

Commit fbcdf8b

Browse files
authored
use clearer pretext update-project
1 parent 7c0a736 commit fbcdf8b

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

pretext/cli.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ def main(ctx: click.Context, targets: bool) -> None:
147147
log.warning(
148148
"Project's CLI version could not be detected from `requirements.txt`."
149149
)
150-
log.warning("Try `pretext update` to produce a compatible file.")
150+
log.warning("Try `pretext update-project` to produce a compatible file.")
151151
elif utils.requirements_version() != VERSION:
152152
log.warning(f"Using CLI version {VERSION} but project's `requirements.txt`")
153153
log.warning(
154154
f"is configured to use {utils.requirements_version()}. Consider either installing"
155155
)
156156
log.warning(
157-
f"CLI version {utils.requirements_version()} or running `pretext update`"
157+
f"CLI version {utils.requirements_version()} or running `pretext update-update`"
158158
)
159159
log.warning(
160160
f"to update `requirements.txt` and other managed files to match {VERSION}."
@@ -214,20 +214,25 @@ def upgrade() -> None:
214214
pretext_cmd = "pretext"
215215
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", pretext_cmd])
216216
log.info(
217-
"Upgrade complete. Individual projects can be updated to align with the latest version of the CLI by running `pretext update` from their project folder."
217+
"Upgrade complete. Individual projects can be updated to align with the latest version of the CLI by running `pretext update-project` from their project folder."
218218
)
219219

220220

221-
# pretext update
221+
@click.command('update')
222+
def old_update():
223+
click.echo("This command is outdated. Use `pretext update-project` instead.")
224+
225+
# pretext update-project
222226
@main.command(
227+
'update-project',
223228
short_help="Update the current project to match the installed version of PreTeXt. Note: to upgrade the installed version of pretext, use `pretext upgrade`.",
224229
context_settings=CONTEXT_SETTINGS,
225230
)
226231
@click.option(
227232
"-b", "--backup", is_flag=True, help="Backup project files before updating."
228233
)
229234
@click.option("-f", "--force", is_flag=True, help="Force update of project files.")
230-
def update(backup: bool, force: bool) -> None:
235+
def update_project(backup: bool, force: bool) -> None:
231236
"""
232237
Update the current project to match the installed version of PreTeXt.
233238
"""

tests/test_cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ def test_init_and_update(tmp_path: Path, script_runner: ScriptRunner) -> None:
200200
assert not (tmp_path / constants.PROJECT_RESOURCES[resource]).exists()
201201
else:
202202
assert (tmp_path / constants.PROJECT_RESOURCES[resource]).exists()
203-
assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success
203+
assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success
204204
for resource in ["requirements.txt", "codechat_config.yaml"]:
205205
resource_path = tmp_path / constants.PROJECT_RESOURCES[resource]
206206
resource_path.unlink(missing_ok=True)
207-
assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success
207+
assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success
208208
for resource in constants.PROJECT_RESOURCES:
209209
if resource in constants.GIT_RESOURCES:
210210
assert not (tmp_path / constants.PROJECT_RESOURCES[resource]).exists()
@@ -217,18 +217,18 @@ def test_init_and_update_with_git(tmp_path: Path, script_runner: ScriptRunner) -
217217
script_runner.run([PTX_CMD, "-v", "debug", "init"], cwd=tmp_path)
218218
for resource in constants.PROJECT_RESOURCES:
219219
assert (tmp_path / constants.PROJECT_RESOURCES[resource]).exists()
220-
assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success
220+
assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success
221221
# Remove resources
222222
for resource in ["requirements.txt", "codechat_config.yaml", ".gitignore"]:
223223
resource_path = tmp_path / constants.PROJECT_RESOURCES[resource]
224224
resource_path.unlink(missing_ok=True)
225-
assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success
225+
assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success
226226
for resource in constants.PROJECT_RESOURCES:
227227
assert (tmp_path / constants.PROJECT_RESOURCES[resource]).exists()
228228
# Ensure modified files don't get updated.
229229
with open(tmp_path / ".gitignore", "a") as f:
230230
f.write("\n# Added by test\n")
231-
assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success
231+
assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success
232232
assert "Added by test" in (tmp_path / ".gitignore").read_text()
233233
# Ensure older version of requirements does get updated.
234234
requirements_path = tmp_path / "requirements.txt"
@@ -240,7 +240,7 @@ def test_init_and_update_with_git(tmp_path: Path, script_runner: ScriptRunner) -
240240
file.write("pretext == 1.0.0\n")
241241
else:
242242
file.write(line)
243-
assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success
243+
assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success
244244
with open(requirements_path, "r") as file:
245245
lines = file.readlines()
246246
assert f"pretext == {pretext.VERSION}\n" in lines[1]

0 commit comments

Comments
 (0)