Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: drop positional directory parameter to idfx clean. Replace it with (optional) --dir parameter, following other commands. #343

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

- API: drop positional `directory` parameter to `idfx clean`. Replace it with (optional)
`--dir` parameter, following other commands.


## [4.0.0] - 2023-10-16

- DEP: migrate prompting from rich to termcolor
Expand Down
8 changes: 5 additions & 3 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,21 @@ Removes intermediate compilation files (`*.o`, `*.host`, `*.cuda`) as well as
CMake cache files and directories

```shell
$ idfx clean .
$ idfx clean
```
This command will print a list of purgable files, and will not remove anything
This command will print a list of purgable files from the current working directory, and will not remove anything
without confirmation (unless confirmation is explicitly skipped with `--no-confirm`).

To also remove `Makefile`, `idefix` executables, use the `--all` flag
```shell
$ idfx clean . --all
$ idfx clean --all
```

Use the `--dry-run/--dry` flag to skip the prompt and only display the list of
purgeable items, without actually deleting anything.

`idfx clean` also accepts a `--dir <path>` argument.

## `idfx clone`

Clone an idefix problem directory by copying the main source files
Expand Down
2 changes: 1 addition & 1 deletion src/idefix_cli/_commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

def add_arguments(parser: ArgumentParser) -> None:
parser.add_argument(
"directory", nargs="?", default=".", help="the target directory to clean"
"--dir", dest="directory", default=".", help="the target directory to clean"
)
parser.add_argument(
"--all",
Expand Down
16 changes: 8 additions & 8 deletions tests/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_clean_no_confirmation(pattern, capsys, tmp_path):
file_to_clean = tmp_path / pattern.replace("*", "legit_file_prefix")
file_to_clean.touch()

ret = main(["clean", str(tmp_path.absolute()), "--no-confirm"])
ret = main(["clean", "--dir", str(tmp_path.absolute()), "--no-confirm"])
assert ret == 0
_out, err = capsys.readouterr()
assert err == ""
Expand All @@ -74,7 +74,7 @@ def test_clean_wildcards(pattern, usr_input, monkeypatch, tmp_path):
file_to_clean.touch()

monkeypatch.setattr("sys.stdin", StringIO(usr_input))
main(["clean", str(tmp_path.absolute())])
main(["clean", "--dir", str(tmp_path.absolute())])

if usr_input in YESES:
assert not list(tmp_path.iterdir())
Expand All @@ -90,7 +90,7 @@ def test_clean_only_kokkos(usr_input, dirty_tmp_dir, monkeypatch):
targets, survivors = (), targets + survivors

monkeypatch.setattr("sys.stdin", StringIO(usr_input))
main(["clean", str(tmp_path.absolute())])
main(["clean", "--dir", str(tmp_path.absolute())])

for name in targets:
assert not name.is_file()
Expand All @@ -108,7 +108,7 @@ def test_clean_all(usr_input, messy_tmp_dir, monkeypatch):
targets, survivors = (), targets + killable + survivors

monkeypatch.setattr("sys.stdin", StringIO(usr_input))
main(["clean", str(tmp_path.absolute()), "--all"])
main(["clean", "--dir", str(tmp_path.absolute()), "--all"])

for name in targets:
assert not name.is_file()
Expand All @@ -122,7 +122,7 @@ def test_clean_all(usr_input, messy_tmp_dir, monkeypatch):
def test_drymode_noop(flags, clean_tmp_dir, capsys):
tmp_path, targets, survivors = clean_tmp_dir

ret = main(["clean", *flags, str(tmp_path.absolute())])
ret = main(["clean", *flags, "--dir", str(tmp_path.absolute())])
assert ret == 0
out, err = capsys.readouterr()
assert out == "Nothing to remove.\n"
Expand All @@ -133,7 +133,7 @@ def test_drymode_noop(flags, clean_tmp_dir, capsys):
def test_drymode_dirty(flag, dirty_tmp_dir, capsys):
tmp_path, targets, survivors = dirty_tmp_dir

ret = main(["clean", flag, str(tmp_path.absolute())])
ret = main(["clean", flag, "--dir", str(tmp_path.absolute())])
assert ret == 0

out, err = capsys.readouterr()
Expand All @@ -147,7 +147,7 @@ def test_drymode_dirty(flag, dirty_tmp_dir, capsys):
def test_drymode_messy(flag, messy_tmp_dir, capsys):
tmp_path, targets, killable, survivors = messy_tmp_dir

ret = main(["clean", flag, str(tmp_path.absolute())])
ret = main(["clean", flag, "--dir", str(tmp_path.absolute())])
assert ret == 0

out, err = capsys.readouterr()
Expand All @@ -161,7 +161,7 @@ def test_drymode_messy(flag, messy_tmp_dir, capsys):
def test_drymode_messy_all(flag, messy_tmp_dir, capsys):
tmp_path, targets, killable, survivors = messy_tmp_dir

ret = main(["clean", str(tmp_path.absolute()), flag, "--all"])
ret = main(["clean", "--dir", str(tmp_path.absolute()), flag, "--all"])
assert ret == 0

out, err = capsys.readouterr()
Expand Down