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():
parser = argparse.ArgumentParser(description='update version records of nvchecker')
core.add_common_arguments(parser)
parser.add_argument('--all', action='store_true',
help='take all updates')
parser.add_argument('names', metavar='NAME', nargs='*',
help='software name to be updated')
args = parser.parse_args()
@ -30,14 +32,17 @@ def take():
oldvers = core.read_verfile(s.oldver)
newvers = core.read_verfile(s.newver)
for name in args.names:
try:
oldvers[name] = newvers[name]
except KeyError:
logger.fatal(
"%s doesn't exist in 'newver' set.", name
)
sys.exit(2)
if args.all:
oldvers.update(newvers)
else:
for name in args.names:
try:
oldvers[name] = newvers[name]
except KeyError:
logger.fatal(
"%s doesn't exist in 'newver' set.", name
)
sys.exit(2)
try:
os.rename(s.oldver, s.oldver + '~')