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
50
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
220
Generating Power with Yield
jasonamyers
1
190
Introduction to SQLAlchemy and Alembic
jasonamyers
4
1.1k
Data Networking for Developers
jasonamyers
0
150
Diabetes and Me
jasonamyers
0
80
UI Functional Testing
jasonamyers
1
120
Other Decks in Technology
See All in Technology
ここは地獄!つらい朝会を体験することで、チームとしてのより良い振る舞いに気づくワークショップ / The stand-up meeting from hell in the game industry
scrummasudar
0
340
Vポイント分析基盤におけるデータモデリング20年史
taromatsui_cccmkhd
4
770
全社でのソフトウェアサプライチェーン攻撃対策をやってみた with Takumi Guard
z63d
0
310
それでも、技術なブログを書く理由 #kichijojipm / Why I Still Write Tech Blogs Even Now
shinkufencer
0
1k
AI時代におけるエンジニアの新たな役割──FDEとクオリアの探求/登壇資料(戸井田 裕貴)
hacobu
PRO
0
510
QA・ソフトウェアテスト研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
2
1k
テックカンファレンス三大ステークホルダーの文化人類学 ─ 違いを認め合う関係性作り
bash0c7
3
820
Multicaで30個のミニプロジェクトをAIエージェント運用して見えてきたこと
eiei114
1
670
AI時代こそ、スケールしないことをしよう -「作る人」から「なぜ作るか」を考える人へ / Do Things That Don't Scale in the AI Era — From How to Why
kaminashi
1
160
どこまでAIに任せるか 〜確率論と決定論の境界決定〜
shukob
0
540
AI時代におけるテストの基礎の再定義 / Rethinking the Fundamentals of Testing in the AI Era
mineo_matsuya
15
5.8k
脱Jenkins、インターン生が挑んだCIツールGitHubActions移行
mixi_engineers
PRO
1
140
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
470
Google's AI Overviews - The New Search
badams
0
1.1k
Building AI with AI
inesmontani
PRO
1
1.1k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
510
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
640
The browser strikes back
jonoalderson
0
1.4k
Context Engineering - Making Every Token Count
addyosmani
9
1k
Color Theory Basics | Prateek | Gurzu
gurzu
0
400
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