Implement --check option
This commit is contained in:
parent
cac52effa8
commit
0d696114b2
19
cli.py
19
cli.py
@ -35,6 +35,11 @@ if __name__ == '__main__':
|
||||
'--funky', '-f', action='store_true',
|
||||
help='List filenames with special characters'
|
||||
)
|
||||
mgroup.add_argument(
|
||||
'--check', '-c', action='store_true',
|
||||
help='Check whether a name is normalised or not'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'files', type=str, nargs='+',
|
||||
help='File(s) to normalise the name of (relative or absolute path).'
|
||||
@ -59,14 +64,24 @@ if __name__ == '__main__':
|
||||
whitelist = whitelist.difference(set(args.disallow))
|
||||
|
||||
# define operations
|
||||
listchanges = lambda a, b: print('{}{} --> {}'.format(a, ' '*(60-len(a)), b))
|
||||
listfunky = lambda a, b: print(a)
|
||||
def listchanges(before, after):
|
||||
print(f'{after}{" "*(60-len(after))} --> {before}')
|
||||
|
||||
def listfunky(before, _):
|
||||
print(before)
|
||||
|
||||
def checkname(before, after):
|
||||
if before != after:
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
operation = rename
|
||||
if args.dryrun:
|
||||
operation = listchanges
|
||||
elif args.funky:
|
||||
operation = listfunky
|
||||
elif args.check:
|
||||
operation = checkname
|
||||
|
||||
# do what needs to be done
|
||||
Normalisename(operation, args.separator, whitelist)(args.files)
|
||||
|
Loading…
Reference in New Issue
Block a user