コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Python】docopt 使用例

ソースコード

"""
Usage:
  hoge.py -h
  hoge.py (--input-path <input-path>) (--output-path <output-path>) (--column <column>) (--start-x <start-x>) (--start-y <start-y>) (--offset-x <offset-x>) (--offset-y <offset-y>) (--height <height>)

Options:
  -h --help                      Show this screen.
  --input-path <input-path>      Input image folder.
  --output-path <output-path>    Output pptx file path.
  --column <column>              Image column.
  --start-x <start-x>            Image start x.
  --start-y <start-y>            Image start y.
  --offset-x <offset-x>          Image offset x.
  --offset-y <offset-y>          Image offst y.
  --height <height>              Image height.
"""

from docopt import docopt

if __name__ == '__main__':
    args = docopt(__doc__)
    print(args["--input-path"])
    print(args["--output-path"])
    print(args["--column"])
    print(args["--start-x"])
    print(args["--start-y"])
    print(args["--offset-x"])
    print(args["--offset-y"])
    print(args["--height"])

使用例

python hoge.py ^
    --input-path hoge ^
    --output-path hogex ^
    --column 3 ^
    --start-x 0.5 ^
    --start-y 0.5 ^
    --offset-x 7.75 ^
    --offset-y 4.5 ^
    --height 4.25