Successfully reported this slideshow.

Introduction to Clime

1

Share

Upcoming SlideShare
Minimal MVC in JavaScript
Minimal MVC in JavaScript
Loading in …3
×
1 of 20
1 of 20

Introduction to Clime

1

Share

Download to read offline

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/.

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/.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Introduction to Clime

  1. 1. Clime Mosky 1
  2. 2. CLI-ize ME It 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 shouldn't be long! # file: db.py def init(): pass def clear(): pass def drop(): pass if __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.py def 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 --help usage: [--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 math usage: 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 End 1. Zero configuration 2. Auto-generates usage 3. Supports aliases and metavars 4. sudo pip install clime 5. http://clime.mosky.tw/ 20

×