correct docopt syntax and validation with schema

This commit is contained in:
LecygneNoir 2018-03-02 14:04:52 +01:00
parent 8863c6856d
commit 3e0865ad43

View file

@ -5,17 +5,17 @@
ptyt_upload - tool to upload videos to Peertube and Youtube
Usage:
ptyt_upload --file=/path/to/video [options]
ptyt_upload -h | --help
ptyt_upload --version
ptyt_upload.py --file=<FILE> [options]
ptyt_upload.py -h | --help
ptyt_upload.py --version
Options:
--file=PATH Path to the video to upload.
--name=STRING Name of the video to upload. (default to video file name)
-d --description=STRING Description of the video.
-t --tags=STRING Tags for the video. (comma separated)
--version Show version.
--name=NAME Name of the video to upload. default to video file name
-d, --description=STRING Description of the video.
-t, --tags=STRING Tags for the video. comma separated
-h --help Show this help.
--version Show version.
"""
@ -54,15 +54,13 @@ if __name__ == '__main__':
import pt_upload
options = docopt(__doc__, version=VERSION)
print options
schema = Schema({
'--file': And(str, lambda s: validateVideo(s), error='file is not supported, please use mp4'),
Optional('--name'): Or(None, And(str, lambda x: not x.isdigit(), error="The video name should be a string")),
Optional('--description'): Or(None, And(str, lambda x: not x.isdigit(), error="The video name should be a string")),
Optional('--d'): Or(None, And(str, lambda x: not x.isdigit(), error="The video name should be a string")),
Optional('--tags'): Or(None, And(str, lambda x: not x.isdigit(), error="Tags should be a string")),
Optional('--t'): Or(None, And(str, lambda x: not x.isdigit(), error="Tags should be a string")),
'-h': bool,
'--help': bool,
'--version': bool
})
@ -72,4 +70,4 @@ if __name__ == '__main__':
except SchemaError as e:
exit(e)
# yt_upload.run(args)
yt_upload.run(options)