Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building CLIs that Click
Search
Jason Myers
May 29, 2015
Technology
0
44
Building CLIs that Click
PyNash presentation on building better CLIs
Jason Myers
May 29, 2015
Tweet
Share
More Decks by Jason Myers
See All by Jason Myers
Introduction to Pandas
jasonamyers
2
200
Generating Power with Yield
jasonamyers
1
180
Introduction to SQLAlchemy and Alembic
jasonamyers
4
1k
Data Networking for Developers
jasonamyers
0
130
Diabetes and Me
jasonamyers
0
61
UI Functional Testing
jasonamyers
1
110
Other Decks in Technology
See All in Technology
結果的にこうなった。から見える メカニズムのようなもの。
recruitengineers
PRO
1
130
Pwned Labsのすゝめ
ken5scal
2
590
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
550
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
2
480
アジャイルな開発チームでテスト戦略の話は誰がする? / Who Talks About Test Strategy?
ak1210
1
920
生成AIがローコードツールになる時代の エンジニアの役割を考える
khwada
0
350
Dify触ってみた。
niftycorp
PRO
0
110
User Story Mapping + Inclusive Team
kawaguti
PRO
3
620
最近のSRE支援ニーズ考察 | sogaoh's LT @ Road to SRE NEXT@札幌
sogaoh
PRO
1
170
x86-64 Assembly Essentials
latte72
4
790
プロダクト開発者目線での Entra ID 活用
sansantech
PRO
0
200
Linuxのブートプロセス
sat
PRO
6
100
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Become a Pro
speakerdeck
PRO
26
5.2k
Done Done
chrislema
182
16k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Side Projects
sachag
452
42k
Site-Speed That Sticks
csswizardry
4
420
Being A Developer After 40
akosma
89
590k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
Fireside Chat
paigeccino
35
3.2k
Facilitating Awesome Meetings
lara
53
6.3k
Navigating Team Friction
lara
183
15k
Transcript
BUILDING CLIS THAT CLICK Created by / Jason A Myers
@jasonamyers
BUILDING GOOD COMMAND LINE APPLICATIONS IS HARD
IMPORTANT PARTS NAME ARGUMENT PARSING AND VALIDATION * HELP GENERATION
* COMMAND STRUCTURE * AUTOCOMPLETION NICE OUTPUT PACKAGING *
ARGUMENTS AND HELP
THREE DIFFERENT PARSERS IN THE STDLIB getopt optparse argparse
I MEAN ARGPARSE IS THE NEW HOTNESS???
SERIOUSLY WHO KNOWS HOW *!@%PARSE WORKS ANYWAY
NO REALLY HAVE YOU LOOKED AT THE DOCS...
None
SERIOUSLY BRAIN CELLS EXPLODE
HOW BAD IS IT? docopt Plac Cliff Clint
import sys if __name__ == "__main__": main(sys.argv)
None
DEMO
LOGGING
GOOD LOGGING MESSAGES Time Module Level Parseable Messages
2015-05-28 09:25:18,711 - complex.logger - DEBUG - Creating composit e:
cookies 2015-05-28 09:25:18,711 - complex.logger - DEBUG - Created composite : cookies
JAM'S LOGGING STYLE
import logging logger = logging.getLogger(__name__) logger.setLevel(logging.ERROR)
file_log_handler = logging.FileHandler('complex-cli.log') logger.addHandler(file_log_handler) stderr_log_handler = logging.StreamHandler() logger.addHandler(stderr_log_handler)
format_string = '%(asctime)s - %(name)s - ' \ '%(levelname)s -
%(message)s' formatter = logging.Formatter(format_string) file_log_handler.setFormatter(formatter) stderr_log_handler.setFormatter(formatter)
PACKAGING
FIND OUR MODULE from setuptools import setup, find_packages setup( name='complex',
version='0.1.2', packages=find_packages(), include_package_data=True,
install_requires=[ 'Click==3.3', ],
description='A description', classifiers=[ 'License :: OSI Approved :: BSD License',
'Programming Language :: Python', 'Programming Language :: Python :: 3', ],
entry_points=''' [console_scripts] complex=complex.command:cli ''' )
COMPLEX DEMO
None
QUESTIONS @JASONAMYERS