Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

Introduction to Clime

  1. Clime Mosky 1
  2. CLI-ize ME It is what the name means! 2
  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. 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. I opened the doc of argparse, argparse, 5
  6. then felt sleepy … 6
  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. But human wants are unlimited! 8
  9. After hardworking, 9
  10. Clime was released. 10
  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. into a CLI program $ python pyramid.py --help usage: [--squash] <story> or: draw [--squash] <story> $ python pyramid.py –-squash=5 3 * *********** ********************* 12
  13. just by adding this line: import clime.now 13
  14. If you like it, 14
  15. $ sudo pip install clime 15
  16. It also supported aliases … def draw(story, squash=1): '''It draws a pyramid. -s, --squash It is optional. ''' … 16
  17. and metavars. … def draw(story, squash=1): '''It draws a pyramid. -s <int>, --squash=<int> ''' … 17
  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. http://clime.mosky.tw/ is the documentation of Clime. 19
  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
Advertisement