From fbcdf8b70ec7e3f9cf4cd4b7852a129cd74a7f58 Mon Sep 17 00:00:00 2001 From: Steven Clontz Date: Tue, 14 Apr 2026 11:13:10 -0500 Subject: [PATCH] use clearer `pretext update-project` --- pretext/cli.py | 15 ++++++++++----- tests/test_cli.py | 12 ++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pretext/cli.py b/pretext/cli.py index 31a0267c..2b565e90 100644 --- a/pretext/cli.py +++ b/pretext/cli.py @@ -147,14 +147,14 @@ def main(ctx: click.Context, targets: bool) -> None: log.warning( "Project's CLI version could not be detected from `requirements.txt`." ) - log.warning("Try `pretext update` to produce a compatible file.") + log.warning("Try `pretext update-project` to produce a compatible file.") elif utils.requirements_version() != VERSION: log.warning(f"Using CLI version {VERSION} but project's `requirements.txt`") log.warning( f"is configured to use {utils.requirements_version()}. Consider either installing" ) log.warning( - f"CLI version {utils.requirements_version()} or running `pretext update`" + f"CLI version {utils.requirements_version()} or running `pretext update-update`" ) log.warning( f"to update `requirements.txt` and other managed files to match {VERSION}." @@ -214,12 +214,17 @@ def upgrade() -> None: pretext_cmd = "pretext" subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", pretext_cmd]) log.info( - "Upgrade complete. Individual projects can be updated to align with the latest version of the CLI by running `pretext update` from their project folder." + "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." ) -# pretext update +@click.command('update') +def old_update(): + click.echo("This command is outdated. Use `pretext update-project` instead.") + +# pretext update-project @main.command( + 'update-project', short_help="Update the current project to match the installed version of PreTeXt. Note: to upgrade the installed version of pretext, use `pretext upgrade`.", context_settings=CONTEXT_SETTINGS, ) @@ -227,7 +232,7 @@ def upgrade() -> None: "-b", "--backup", is_flag=True, help="Backup project files before updating." ) @click.option("-f", "--force", is_flag=True, help="Force update of project files.") -def update(backup: bool, force: bool) -> None: +def update_project(backup: bool, force: bool) -> None: """ Update the current project to match the installed version of PreTeXt. """ diff --git a/tests/test_cli.py b/tests/test_cli.py index 9bfc9a29..899e916a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -200,11 +200,11 @@ def test_init_and_update(tmp_path: Path, script_runner: ScriptRunner) -> None: assert not (tmp_path / constants.PROJECT_RESOURCES[resource]).exists() else: assert (tmp_path / constants.PROJECT_RESOURCES[resource]).exists() - assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success + assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success for resource in ["requirements.txt", "codechat_config.yaml"]: resource_path = tmp_path / constants.PROJECT_RESOURCES[resource] resource_path.unlink(missing_ok=True) - assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success + assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success for resource in constants.PROJECT_RESOURCES: if resource in constants.GIT_RESOURCES: 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) - script_runner.run([PTX_CMD, "-v", "debug", "init"], cwd=tmp_path) for resource in constants.PROJECT_RESOURCES: assert (tmp_path / constants.PROJECT_RESOURCES[resource]).exists() - assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success + assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success # Remove resources for resource in ["requirements.txt", "codechat_config.yaml", ".gitignore"]: resource_path = tmp_path / constants.PROJECT_RESOURCES[resource] resource_path.unlink(missing_ok=True) - assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success + assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success for resource in constants.PROJECT_RESOURCES: assert (tmp_path / constants.PROJECT_RESOURCES[resource]).exists() # Ensure modified files don't get updated. with open(tmp_path / ".gitignore", "a") as f: f.write("\n# Added by test\n") - assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success + assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success assert "Added by test" in (tmp_path / ".gitignore").read_text() # Ensure older version of requirements does get updated. requirements_path = tmp_path / "requirements.txt" @@ -240,7 +240,7 @@ def test_init_and_update_with_git(tmp_path: Path, script_runner: ScriptRunner) - file.write("pretext == 1.0.0\n") else: file.write(line) - assert script_runner.run([PTX_CMD, "-v", "debug", "update"], cwd=tmp_path).success + assert script_runner.run([PTX_CMD, "-v", "debug", "update-project"], cwd=tmp_path).success with open(requirements_path, "r") as file: lines = file.readlines() assert f"pretext == {pretext.VERSION}\n" in lines[1]