Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Clime

6,708 views

Published on

Clime is a Python library which lets you convert any module into a multi-command CLI program without any configuration.

It is a short tour of Clime.

The full documentation of Clime: http://clime.mosky.tw/.

Published in: Software
  • Be the first to comment

Introduction to Clime

  1. 1. ClimeMosky 1
  2. 2. CLI-ize MEIt is what the name means! 2
  3. 3. Writing A CLI program● It is not difficult with a library. (ex. argparse)● But it is annoying, especially for the simple tasks. 3
  4. 4. At one midnight ...I was thinking about the schema of the database.● initdb.py ● db.py init● cleardb.py ● db.py clear● dropdb.py ● db.py drop ... ... 4
  5. 5. I opened the doc of argparse, argparse, 5
  6. 6. then felt sleepy … 6
  7. 7. It shouldnt be long!# file: db.pydef init(): passdef clear(): passdef drop(): passif __name__ == __main__: import sys locals()[sys.argv[1]]() 7
  8. 8. But human wants are unlimited! 8
  9. 9. After hardworking, 9
  10. 10. Clime was released. 10
  11. 11. It converts your program# file: pyramid.pydef draw(story, squash=1): ground_len = 1 + (story-1) * squash * 2 for i in range(1, ground_len+1, squash*2): print (**i).center(ground_len) 11
  12. 12. into a CLI program$ python pyramid.py --helpusage: [--squash] <story> or: draw [--squash] <story>$ python pyramid.py –-squash=5 3 * ******************************** 12
  13. 13. just by adding this line: import clime.now 13
  14. 14. If you like it, 14
  15. 15. $ sudo pip install clime 15
  16. 16. It also supported aliases…def draw(story, squash=1): It draws a pyramid. -s, --squash It is optional. … 16
  17. 17. and metavars.…def draw(story, squash=1): It draws a pyramid. -s <int>, --squash=<int> … 17
  18. 18. It is also an executable module.$ python -m clime mathusage: acos <x> or: acosh <x> or: asin <x> or: asinh <x> or: atan <x>… 18
  19. 19. http://clime.mosky.tw/ is the documentation of Clime. 19
  20. 20. The End1. Zero configuration2. Auto-generates usage3. Supports aliases and metavars4. sudo pip install clime5. http://clime.mosky.tw/ 20

×