Skip to content

Commit 42da9ad

Browse files
new: add arg --silent
1 parent e70e134 commit 42da9ad

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

WDoc/WDoc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def __init__(
131131
DIY_rolling_window_embedding: Union[bool, int] = False,
132132
import_mode: Union[bool, int] = False,
133133
disable_md_printing: bool = False,
134+
silent: bool = False,
134135
version: bool = False,
135136

136137
**cli_kwargs,

WDoc/docs/USAGE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,16 @@
222222
the default langchain SentenceTransformerEmbedding implementation
223223

224224
* `--import_mode`: bool, default `False`
225-
* if True, will return the answer from query instead of printing it
225+
* if True, will return the answer from query instead of printing it.
226+
The idea is to use if when you import WDoc instead of running
227+
it from the cli. See `--silent`
226228

227229
* `--disable_md_printing`: bool, default `True`
228230
* if True, instead of using rich to display some information, default to simpler colored prints.
229231

232+
* `--silent`: bool, default False
233+
* disable almost all prints. Can be handy if `--import_mode` is used.
234+
230235
* `--version`: bool, default False
231236
* display the version and exit
232237

WDoc/utils/flags.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ def check_kwargs(arg):
1717
is_debug = check_kwargs("debug")
1818
is_verbose = is_debug or check_kwargs("verbose")
1919

20+
is_silent = check_kwargs("silent")
2021

2122
disable_md_printing = check_kwargs("disable_md_printing")

WDoc/utils/logger.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import warnings
1515

1616
from .typechecker import optional_typecheck
17-
from .flags import disable_md_printing
17+
from .flags import disable_md_printing, is_silent
1818

1919
# ignore warnings from beautiful soup
2020
warnings.filterwarnings("ignore", category=UserWarning, module='bs4')
@@ -85,7 +85,8 @@ def printer(string: Union[str, Dict, List], **args) -> str:
8585
for k, v in colors.items():
8686
string = string.replace(v, "")
8787
logger.info(string)
88-
tqdm.write(col + string + colors["reset"], **args)
88+
if not is_silent:
89+
tqdm.write(col + string + colors["reset"], **args)
8990
return inp
9091
return printer
9192

0 commit comments

Comments
 (0)