Skip to content

Commit c5e5109

Browse files
committed
add verbose option
1 parent ff13aec commit c5e5109

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/publish-to-test-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on: push
99
jobs:
1010
build-n-publish:
1111
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
12-
runs-on: ubuntu-18.04
12+
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@master
1515
- name: Set up Python 3.8

devpack/batch_tools.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ def auto_add_readme(
3232
readme_name: str = "README.md",
3333
root_path: Optional[Path] = Path.cwd(),
3434
prefix="# ",
35+
verbose: bool = True,
3536
) -> None:
3637
"""
3738
Add a readme to the root_path if it does not exist
3839
40+
:param verbose:
41+
:type verbose:
3942
:param path:
4043
:param touch_mode:
4144
:param readme_name:
@@ -48,6 +51,8 @@ def auto_add_readme(
4851
readme_file = path / readme_name
4952
if not readme_file.exists():
5053
readme_file.touch()
54+
if verbose:
55+
print(f"Created {readme_file}")
5156
if touch_mode == TouchModeEnum.breadcrumb:
5257
assert root_path is not None
5358
readme_file.write_text(prefix + str(path.relative_to(root_path)))
@@ -87,6 +92,7 @@ def recursive_add_readmes(
8792
touch_mode: TouchModeEnum = TouchModeEnum.breadcrumb,
8893
readme_name: str = "README.md",
8994
root_path: Optional[Path] = None,
95+
verbose: bool = True,
9096
) -> None:
9197
"""
9298
recursively add readmes to all children spanning from root_path
@@ -97,7 +103,11 @@ def recursive_add_readmes(
97103
root_path = path.parent
98104

99105
auto_add_readme(
100-
path, touch_mode=touch_mode, readme_name=readme_name, root_path=root_path
106+
path,
107+
touch_mode=touch_mode,
108+
readme_name=readme_name,
109+
root_path=root_path,
110+
verbose=verbose,
101111
)
102112

103113
for child in path.iterdir():
@@ -109,6 +119,7 @@ def recursive_add_readmes(
109119
touch_mode=touch_mode,
110120
readme_name=readme_name,
111121
root_path=root_path,
122+
verbose=verbose,
112123
)
113124
elif child.is_file():
114125
pass

devpack/entry_points/batch.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import argparse
1313
from pathlib import Path
14+
from tabnanny import verbose
1415

1516
from devpack.batch_tools import TouchModeEnum, recursive_add_readmes
1617

@@ -33,10 +34,16 @@ def recursively_add_readmes_from_here():
3334
parser.add_argument(
3435
"--readme-name", "-r", type=str, default="README.md", help="Readme name"
3536
)
37+
parser.add_argument(
38+
"--verbose", action="store_true", help="Verbose output of touched files"
39+
)
3640
args = parser.parse_args()
3741

3842
recursive_add_readmes(
39-
args.path, touch_mode=args.touch_mode, readme_name=args.readme_name
43+
args.path,
44+
touch_mode=args.touch_mode,
45+
readme_name=args.readme_name,
46+
verbose=args.verbose,
4047
)
4148

4249

0 commit comments

Comments
 (0)