From fbcdf8b70ec7e3f9cf4cd4b7852a129cd74a7f58 Mon Sep 17 00:00:00 2001 From: Steven Clontz Date: Tue, 14 Apr 2026 11:13:10 -0500 Subject: [PATCH 1/5] 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] From 6d527ad36b28affa02ee078e66dabc9ab0c06a41 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Fri, 29 May 2026 14:04:44 -0600 Subject: [PATCH 2/5] format --- pretext/cli.py | 5 +++-- tests/test_cli.py | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pretext/cli.py b/pretext/cli.py index 2b565e90..ca6ed915 100644 --- a/pretext/cli.py +++ b/pretext/cli.py @@ -218,13 +218,14 @@ def upgrade() -> None: ) -@click.command('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', + "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, ) diff --git a/tests/test_cli.py b/tests/test_cli.py index 899e916a..1709b296 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -200,11 +200,15 @@ 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-project"], 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-project"], 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 +221,24 @@ 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-project"], 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-project"], 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-project"], 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 +250,9 @@ 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-project"], 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] From 2d94aa5e31ac2c2bcabe9731d3deed2bd56ddbda Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Fri, 29 May 2026 14:06:31 -0600 Subject: [PATCH 3/5] Apply suggestion from @oscarlevin --- pretext/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretext/cli.py b/pretext/cli.py index ca6ed915..4f7240bf 100644 --- a/pretext/cli.py +++ b/pretext/cli.py @@ -154,7 +154,7 @@ def main(ctx: click.Context, targets: bool) -> None: f"is configured to use {utils.requirements_version()}. Consider either installing" ) log.warning( - f"CLI version {utils.requirements_version()} or running `pretext update-update`" + f"CLI version {utils.requirements_version()} or running `pretext update-project`" ) log.warning( f"to update `requirements.txt` and other managed files to match {VERSION}." From f4c52511c54d9c06fae7dc2a8b2e32b1862f063f Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Fri, 29 May 2026 14:11:36 -0600 Subject: [PATCH 4/5] fix types --- pretext/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pretext/cli.py b/pretext/cli.py index 4f7240bf..76c286e6 100644 --- a/pretext/cli.py +++ b/pretext/cli.py @@ -219,10 +219,11 @@ def upgrade() -> None: @click.command("update") -def old_update(): +def old_update() -> None: click.echo("This command is outdated. Use `pretext update-project` instead.") + # pretext update-project @main.command( "update-project", From 5d3e2c52e788a511d8e977f24fc64a015409a057 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Fri, 29 May 2026 14:13:20 -0600 Subject: [PATCH 5/5] format --- pretext/cli.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pretext/cli.py b/pretext/cli.py index 76c286e6..d182c00b 100644 --- a/pretext/cli.py +++ b/pretext/cli.py @@ -223,7 +223,6 @@ def old_update() -> None: click.echo("This command is outdated. Use `pretext update-project` instead.") - # pretext update-project @main.command( "update-project",