nvtake: add support for '--all'

fixes #60
This commit is contained in:
lilydjwg 2017-08-30 14:27:00 +08:00
parent dfbc91f22e
commit 156e281a82
1 changed files with 13 additions and 8 deletions

View File

@ -14,6 +14,8 @@ logger = logging.getLogger(__name__)
def take(): def take():
parser = argparse.ArgumentParser(description='update version records of nvchecker') parser = argparse.ArgumentParser(description='update version records of nvchecker')
core.add_common_arguments(parser) core.add_common_arguments(parser)
parser.add_argument('--all', action='store_true',
help='take all updates')
parser.add_argument('names', metavar='NAME', nargs='*', parser.add_argument('names', metavar='NAME', nargs='*',
help='software name to be updated') help='software name to be updated')
args = parser.parse_args() args = parser.parse_args()
@ -30,6 +32,9 @@ def take():
oldvers = core.read_verfile(s.oldver) oldvers = core.read_verfile(s.oldver)
newvers = core.read_verfile(s.newver) newvers = core.read_verfile(s.newver)
if args.all:
oldvers.update(newvers)
else:
for name in args.names: for name in args.names:
try: try:
oldvers[name] = newvers[name] oldvers[name] = newvers[name]