Skip to content

Commit b4490ed

Browse files
authored
Merge v3.0.4 to main
2 parents bcdda75 + 4b25c48 commit b4490ed

File tree

15 files changed

+562
-499
lines changed

15 files changed

+562
-499
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,37 @@ assignees: Drugsosos
77

88
---
99

10-
**Describe the bug**
11-
A clear and concise description of what the bug is.
10+
Describe The Bug
11+
---
12+
13+
_A clear and concise description of what the bug is._
14+
15+
Version
16+
---
17+
18+
_Specify the version where the bug appeared_
19+
20+
How To Reproduce
21+
---
22+
23+
_Steps to reproduce the behavior_
1224

13-
**To Reproduce**
14-
Steps to reproduce the behavior:
1525
1. Go to '...'
1626
2. Click on '....'
1727
3. Scroll down to '....'
18-
4. See error
28+
4. See something
29+
30+
Expected Behavior
31+
---
1932

20-
**Expected behavior**
21-
A clear and concise description of what you expected to happen.
33+
_A clear and concise description of what you expect to happen._
2234

23-
**Screenshots**
24-
If applicable, add screenshots to help explain your problem.
35+
Screenshots
36+
---
37+
38+
_If applicable, add screenshots to help explain your problem._
39+
40+
Additional Context
41+
---
2542

26-
**Additional context**
27-
Add any other context about the problem here.
43+
_Add any other context about the problem here._

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,25 @@ assignees: Drugsosos
77

88
---
99

10-
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10+
Is your feature request related to a problem?
11+
---
12+
13+
_A clear and concise description of what the problem is._
14+
15+
#### Example
16+
> I'm always frustrated when [...]
17+
18+
Describe the solution you'd like
19+
---
1220

13-
**Describe the solution you'd like**
14-
A clear and concise description of what you want to happen.
21+
_A clear and concise description of what you want to happen._
1522

16-
**Describe alternatives you've considered**
17-
A clear and concise description of any alternative solutions or features you've considered.
23+
Describe alternatives you've considered
24+
---
25+
26+
_A clear and concise description of any alternative solutions or features you've considered._
27+
28+
Additional Context
29+
---
1830

19-
**Additional context**
20-
Add any other context or screenshots about the feature request here.
31+
_Add any other context or screenshots about the feature request here._
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
name: Questions
3-
about: Describe your question here
3+
about: Ask your questions here
44
title: ''
55
labels: question
66
assignees: Drugsosos
77

88
---
99

10-
**Question**
11-
Describe details of your question here.
10+
Question
11+
---
12+
13+
_Describe details of your question here._

.github/pull_request_template.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
### Title of Pull Request
1+
Title of Pull Request
2+
---
23

3-
Fixes #[Issue Number]
4+
#### Example
5+
> Fixes #[Issue Number]
46
5-
#### Description
7+
Description
8+
---
69

710
_Briefly describe the changes in this pull request._
811

912
- [Summary of major changes]
1013
- [Summary of minor changes]
1114
- [Any other relevant information]
1215

13-
#### Type of Change
16+
Type of Change
17+
---
1418

1519
Please delete options that are not relevant.
1620

@@ -19,15 +23,17 @@ Please delete options that are not relevant.
1923
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
2024
- [ ] This change requires a documentation update
2125

22-
#### How Has This Been Tested?
26+
How Has This Been Tested?
27+
---
2328

2429
Please describe the tests that you ran to verify your changes.
2530
Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
2631

2732
- [ ] Test A
2833
- [ ] Test B
2934

30-
#### Checklist:
35+
Checklist
36+
---
3137

3238
- [ ] My code follows the style guidelines of this project
3339
- [ ] I have performed a self-review of my own code
@@ -39,10 +45,12 @@ Provide instructions so we can reproduce. Please also list any relevant details
3945
- [ ] New and existing unit tests pass locally with my changes
4046
- [ ] Any dependent changes have been merged and published in downstream modules
4147

42-
#### Screenshots (if applicable)
48+
Screenshots
49+
---
4350

4451
_Attach screenshots or screen recordings of the changes, if any._
4552

46-
#### Additional Context
53+
Additional Context
54+
---
4755

4856
_Add any other context or information about the pull request here._

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ $ mac-cleanup -h
108108
usage: mac-cleanup [-h] [-n] [-u] [-c] [-p]
109109
110110
A Mac Cleanup Utility in Python
111-
3.0.3
111+
3.0.4
112112
https://github.com/mac-cleanup/mac-cleanup-py
113113
114114
options:

bumpVersion.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /bin/bash
2+
3+
# Check no version
4+
if [[ -z "$1" ]]; then echo "No version supplied"; exit 1; fi
5+
6+
# Check incorrect version
7+
if ! echo "$1" | grep -Eq '^[0-9]+\.[0-9]\.[0-9]+$'; then echo "Incorrect version"; exit 1; fi
8+
9+
# Get current version
10+
currentVersion="$(grep -oE '(?:^version = \")(\d|\.)+(?:\")' pyproject.toml | sed -r 's/^version = "(([0-9]|\.)+)"/\1/g')"
11+
12+
# Replace in pyproject
13+
sed -ri "" "s/^version = \"$currentVersion\"/version = \"$1\"/g" ./pyproject.toml
14+
15+
# Replace in README
16+
sed -ri "" "s/$currentVersion/$1/g" ./README.md
17+
18+
exit 0

mac_cleanup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
from mac_cleanup.parser import args # isort: skip_file
12
from mac_cleanup.core import ProxyCollector as Collector
23
from mac_cleanup.core_modules import Command, Path
34
from mac_cleanup.main import EntryPoint
4-
from mac_cleanup.parser import args
55

66
try:
77
from mac_cleanup.__version__ import __version__

mac_cleanup/core_modules.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from beartype import beartype # pyright: ignore [reportUnknownVariableType]
77

8+
from mac_cleanup import args
89
from mac_cleanup.progress import ProgressBar
910
from mac_cleanup.utils import check_deletable, check_exists, cmd
1011

@@ -27,6 +28,9 @@ def with_prompt(self: T, message_: Optional[str] = None) -> T:
2728
:class: `BaseModule`
2829
"""
2930

31+
if args.force:
32+
return self
33+
3034
# Can't be solved without typing.Self
3135
self.__prompt = True # pyright: ignore [reportGeneralTypeIssues]
3236

@@ -73,11 +77,11 @@ def get_command(self) -> Optional[str]:
7377
return self.__command
7478

7579
@abstractmethod
76-
def _execute(self, **kwargs: bool) -> Optional[str]:
80+
def _execute(self, ignore_errors: bool = True) -> Optional[str]:
7781
"""
7882
Execute the command specified.
7983
80-
:param ignore_errors_: Ignore errors during execution
84+
:param ignore_errors: Ignore errors during execution
8185
:return: Command execution results based on specified parameters
8286
"""
8387

@@ -90,7 +94,7 @@ def _execute(self, **kwargs: bool) -> Optional[str]:
9094
return
9195

9296
# Execute command
93-
return cmd(command=self.__command, ignore_errors=kwargs.get("ignore_errors", True))
97+
return cmd(command=self.__command, ignore_errors=ignore_errors)
9498

9599

96100
@final
@@ -106,8 +110,15 @@ def with_errors(self) -> "Command":
106110

107111
return self
108112

109-
def _execute(self) -> Optional[str]:
110-
return super()._execute(ignore_errors=self.__ignore_errors)
113+
def _execute(self, ignore_errors: Optional[bool] = None) -> Optional[str]:
114+
"""
115+
Execute the command specified.
116+
117+
:param ignore_errors: Overrides flag `ignore_errors` in class
118+
:return: Command execution results based on specified parameters
119+
"""
120+
121+
return super()._execute(ignore_errors=self.__ignore_errors if ignore_errors is None else ignore_errors)
111122

112123

113124
@final
@@ -137,7 +148,7 @@ def dry_run_only(self) -> "Path":
137148

138149
return self
139150

140-
def _execute(self) -> Optional[str]:
151+
def _execute(self, ignore_errors: bool = True) -> Optional[str]:
141152
"""Delete specified path :return: Command execution results based on specified
142153
parameters.
143154
"""
@@ -149,4 +160,4 @@ def _execute(self) -> Optional[str]:
149160
if not all([check_deletable(path=self.__path), check_exists(path=self.__path, expand_user=False)]):
150161
return
151162

152-
return super()._execute() # Always ignore errors
163+
return super()._execute(ignore_errors=ignore_errors)

mac_cleanup/default_modules.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,25 @@ def inactive_memory():
417417
with clc as unit:
418418
unit.message("Purging inactive memory")
419419
unit.add(Command("sudo purge"))
420+
421+
422+
def telegram():
423+
from mac_cleanup.utils import cmd
424+
425+
with clc as unit:
426+
unit.message("Clear old Telegram cache")
427+
428+
reopen_telegram = False
429+
430+
if cmd("ps aux | grep '[T]elegram'"):
431+
reopen_telegram = True
432+
unit.add(Command("killall -KILL Telegram"))
433+
434+
unit.add(
435+
Path("~/Library/Group Containers/*.ru.keepcoder.Telegram/stable/account-*/postbox/db").with_prompt(
436+
"Telegram cache will be deleted. Once reopened, cache will be rebuild smaller. Continue?"
437+
)
438+
)
439+
440+
if reopen_telegram:
441+
unit.add(Command("open /Applications/Telegram.app"))

mac_cleanup/parser.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Args:
1414
update: bool = attr.ib(default=False)
1515
configure: bool = attr.ib(default=False)
1616
custom_path: bool = attr.ib(default=False)
17+
force: bool = attr.ib(default=False)
1718

1819

1920
parser = ArgumentParser(
@@ -25,17 +26,20 @@ class Args:
2526
formatter_class=RawTextHelpFormatter,
2627
)
2728

28-
parser.add_argument("-n", "--dry-run", help="Dry run without deleting stuff", action="store_true")
29+
parser.add_argument("-n", "--dry-run", help="Run without deleting stuff", action="store_true")
2930

30-
parser.add_argument("-u", "--update", help="Update HomeBrew on cleanup", action="store_true")
31+
parser.add_argument("-u", "--update", help="Update Homebrew on cleanup", action="store_true")
3132

32-
parser.add_argument("-c", "--configure", help="Configure default and custom modules", action="store_true")
33+
parser.add_argument("-c", "--configure", help="Open module configuration screen", action="store_true")
3334

3435
parser.add_argument("-p", "--custom-path", help="Specify path for custom modules", action="store_true")
3536

37+
parser.add_argument("-f", "--force", help="Accept all warnings", action="store_true")
38+
3639
args = Args()
3740
parser.parse_args(namespace=args)
3841

3942
# args.dry_run = True # debug
4043
# args.configure = True # debug
4144
# args.custom_path = True # debug
45+
# args.force = True # debug

0 commit comments

Comments
 (0)