Repository: python-poetry/poetry

Issue:
`poetry cache clear` no longer respects `--no-interaction` flag
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: Ubuntu 22.04
- **Poetry version**: 1.2.0
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: <!-- Gist Link Here -->

## Issue
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->
Since poetry version 1.2.0, the `poetry cache clear` command no longer respects the `--no-interaction` flag:

```
$ poetry cache clear --all --no-interaction .
Delete 1882 entries? (yes/no) [no] ^C
```






Discussion:
duplicate #6212, please close
Not quite duplicate, but known and tracked by two different PRs at different points. I'll leave this open since we didn't have an issue tracking it (and the author may not come back to that PR).
It is not really an upstream issue, I explained it [here](https://github.com/python-poetry/poetry/pull/6212#issuecomment-1223620668)
I was referring to python-poetry/cleo#234 -- or did I misunderstand, and was that fix not needed for this particular usage in Poetry?
> I was referring to [python-poetry/cleo#234](https://github.com/python-poetry/cleo/pull/234) -- or did I misunderstand, and was that fix not needed for this particular usage in Poetry?

Kinda, but the explanation I linked also stands if I remember correctly. I will check it, but 90% sure python-poetry/cleo#234 is not enough

Resolving patch:
diff --git a/src/poetry/console/commands/cache/clear.py b/src/poetry/console/commands/cache/clear.py
--- a/src/poetry/console/commands/cache/clear.py
+++ b/src/poetry/console/commands/cache/clear.py
@@ -55,7 +55,7 @@ def handle(self) -> int:
                 len(files) for _path, _dirs, files in os.walk(str(cache_dir))
             )
 
-            delete = self.confirm(f"<question>Delete {entries_count} entries?</>")
+            delete = self.confirm(f"<question>Delete {entries_count} entries?</>", True)
             if not delete:
                 return 0
 
@@ -73,7 +73,7 @@ def handle(self) -> int:
                 self.line(f"No cache entries for {package}:{version}")
                 return 0
 
-            delete = self.confirm(f"Delete cache entry {package}:{version}")
+            delete = self.confirm(f"Delete cache entry {package}:{version}", True)
             if not delete:
                 return 0
 


Test patch: