introduction to clime
DESCRIPTION
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/.TRANSCRIPT
![Page 1: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/1.jpg)
1
ClimeClimeMoskyMosky
![Page 2: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/2.jpg)
2
CLI-ize MECLI-ize MEIt is what the name means!It is what the name means!
![Page 3: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/3.jpg)
3
Writing A CLI programWriting A CLI program
● It is not difficult with a library. (ex. argparse)● But it is annoying,
especially for the simple tasks.
![Page 4: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/4.jpg)
4
At one midnight ...At one midnight ...
I was thinking about the schema of the database.● initdb.py● cleardb.py● dropdb.py
...
● db.py init● db.py clear● db.py drop
...
![Page 5: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/5.jpg)
5
I opened the doc of I opened the doc of argparseargparse,,
![Page 6: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/6.jpg)
6
then felt sleepy … then felt sleepy …
![Page 7: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/7.jpg)
7
It shouldn't be long!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]]()
![Page 8: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/8.jpg)
8
But human wants are unlimited!But human wants are unlimited!
![Page 9: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/9.jpg)
9
After hardworking,After hardworking,
![Page 10: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/10.jpg)
10
Clime was released.Clime was released.
![Page 11: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/11.jpg)
11
It converts your programIt 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)
![Page 12: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/12.jpg)
12
into a CLI programinto a CLI program
$ python pyramid.py --help
usage: [--squash] <story>
or: draw [--squash] <story>
$ python pyramid.py –-squash=5 3
*
***********
*********************
![Page 13: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/13.jpg)
13
just by adding this line:just by adding this line:
import clime.now
![Page 14: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/14.jpg)
14
If you like it,If you like it,
![Page 15: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/15.jpg)
15
$ sudo pip install clime$ sudo pip install clime
![Page 16: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/16.jpg)
16
It also supported aliasesIt also supported aliases
…
def draw(story, squash=1):
'''It draws a pyramid.
-s, --squash It is optional.
'''
…
![Page 17: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/17.jpg)
17
and metavars.and metavars.
…
def draw(story, squash=1):
'''It draws a pyramid.
-s <int>, --squash=<int>
'''
…
![Page 18: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/18.jpg)
18
It is also an executable module.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>
…
![Page 19: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/19.jpg)
19
http://clime.mosky.tw/http://clime.mosky.tw/is the documentation of Clime.is the documentation of Clime.
![Page 20: Introduction to Clime](https://reader033.vdocument.in/reader033/viewer/2022052900/55632a8ad8b42ad7398b4ee5/html5/thumbnails/20.jpg)
20
The EndThe End
1. Zero configuration
2. Auto-generates usage
3. Supports aliases and metavars
4.sudo pip install clime
5. http://clime.mosky.tw/