Skip to content

Commit e46d5fd

Browse files
committed
Feature: Add --yes -Y to skip confirmation
1 parent b423158 commit e46d5fd

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ optional arguments:
8989
--directory -D use a vaild dir path specify the pdf save directory.
9090
--output -o add --output filename to appoint name of pdf file
9191
--loglevel -l set the console log level, e.g debug
92+
--yes -Y add --yes or -Y to skip the confirmation process before search
9293
----
9394

9495
*If you are familiar with IDEs, you can run `main.py` in Python environments such as `pycharm` or `vscode`.*

README_CN.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ optional arguments:
9494
--downloadnum,-d a digit number to specify the number to download
9595
--directory -D use a vaild dir path specify the pdf save directory.
9696
--output -o add --output filename to appoint name of pdf file
97-
--loglevel -l set the console log level, e.g debug
97+
98+
--loglevel -l set the console log level, e.g -l debug
99+
--yes -Y add --yes to skip the confirmation process before searching
98100
----
99101

100102
_如果你熟悉IDE的话,可以在pycharm或者vscode等python环境下运行main.py_
101103

102104
. 根据提示输入 `y` 或者 `n` 决定是否以给定的参数执行程序
103105

106+
可以通过附加 `-Y` 参数来跳过二次确认过程
107+
104108
image:assets/pubmedsoso_teminal.png[comfirm picture, 600]
105109

106110
**pubmedsoso会按照你正常搜索的顺序进行爬取下载**

main.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def printSpliter(length=25):
2828
description="pubmedsoso is a python program for crawler article information and download pdf file",
2929
usage="python main.py -k keyword")
3030

31-
parser.add_argument('-v', '--version', action='version',
31+
parser.add_argument('-v ', '--version', action='version',
3232
version=f'\nCurrent the {ProjectInfo.ProjectName}\n\n version: {ProjectInfo.VersionInfo}\n' +
3333
f'Last updated date: {ProjectInfo.LastUpdate} \n' +
3434
f'Author: {ProjectInfo.AuthorName} \n',
@@ -85,7 +85,14 @@ def printSpliter(length=25):
8585
parser.add_argument("-l", "--loglevel", metavar='',
8686
choices=('debug', 'info', 'warning', 'error', 'critical'),
8787
help='set the terminal log level while the file log level'
88-
' can only be configured in config.py. Default log level is info', default=None)
88+
'the choice of loglevel is "debug" "info" "warning" "error" "critical" '
89+
' can only be configured in config.py. Default log level is info'
90+
' ', default=None)
91+
92+
parser.add_argument("-Y ", "--yes", action="store_true",
93+
help='add --yes or -Y to skip the confirmation process and start searching directly',
94+
default=False)
95+
8996
# todo
9097
# add mutual exclusive group for some args
9198

@@ -135,10 +142,13 @@ def printSpliter(length=25):
135142
except Exception as err:
136143
raise
137144

138-
if os.getenv("DEBUG"):
145+
medLog.info("当前关键词在pubmed检索到的相关结果数量为: %s\n" % result_num)
146+
147+
# add --yes parameter to skip the confirmation
148+
if args.Yes is True:
139149
pass
140150
else:
141-
medLog.info("当前关键词在pubmed检索到的相关结果数量为: %s\n" % result_num)
151+
142152
medLog.info("是否要根据以上参数开始执行程序?y or n\n")
143153
startFlag = input()
144154
if startFlag == 'y' or startFlag == 'Y' or startFlag == 'Yes':

0 commit comments

Comments
 (0)