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
48
0
Share
Building CLIs that Click
PyNash presentation on building better CLIs
Jason Myers
May 29, 2015
More Decks by Jason Myers
See All by Jason Myers
Introduction to Pandas
jasonamyers
2
210
Generating Power with Yield
jasonamyers
1
180
Introduction to SQLAlchemy and Alembic
jasonamyers
4
1.1k
Data Networking for Developers
jasonamyers
0
140
Diabetes and Me
jasonamyers
0
75
UI Functional Testing
jasonamyers
1
120
Other Decks in Technology
See All in Technology
#jawsugyokohama 100 LT11, "My AWS Journey 2011-2026 - kwntravel"
shinichirokawano
0
350
AI와 협업하는 조직으로의 여정
arawn
0
470
実践ハーネスエンジニアリング:TAKTで実現するAIエージェント制御 / Practical Harness Engineering: AI Agent Control Enabled by TAKT
nrslib
11
4.6k
AWS認定資格は本当に意味があるのか?
nrinetcom
PRO
2
280
Chasing Real-Time Observability for CRuby
whitegreen
0
170
AndroidアプリとCopilot Studioの統合
nakasho
0
110
自分のハンドルは自分で握れ! ― 自分のケイパビリティを増やし、メンバーのケイパビリティ獲得を支援する ― / Take the wheel yourself
takaking22
1
920
ハーネスエンジニアリングをやりすぎた話 ~そのハーネスは解体された~
gotalab555
4
1.8k
みんなの「データ活用」を支えるストレージ担当から持ち込むAWS活用/コミュニティー設計TIPS 10選~「作れる」より、「続けられる」設計へ~
yoshiki0705
0
250
明日からドヤれる!超マニアックなAWSセキュリティTips10連発 / 10 Ultra-Niche AWS Security Tips
yuj1osm
0
600
260420_スマートホーム採用説明 - wakinchan
wakinchan
0
110
20260423_執筆の工夫と裏側 技術書の企画から刊行まで / From the planning to the publication of technical book
nash_efp
3
410
Featured
See All Featured
Mind Mapping
helmedeiros
PRO
1
160
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
180
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
250
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
740
Music & Morning Musume
bryan
47
7.2k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
260
HDC tutorial
michielstock
2
630
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
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