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
The essence of decision-making lies in primary data
kaminashi
0
240
自分をひらくと次のチャレンジの敷居が下がる
sudoakiy
5
1.7k
レガシーシステムをどう次世代に受け継ぐか
tachiiri
0
180
最大のアウトプット術は問題を作ること
ryoaccount
0
280
推し活エージェント
yuntan_t
1
720
GitHub Advanced Security × Defender for Cloudで開発とSecOpsのサイロを超える: コードとクラウドをつなぐ、開発プラットフォームのセキュリティ
yuriemori
1
120
FASTでAIエージェントを作りまくろう!
yukiogawa
4
190
ZOZOTOWNリプレイスでのSkills導入までの流れとこれから.pptx.pdf
zozotech
PRO
2
320
Babylon.js Japan Activities (2026/4)
limes2018
0
160
AWS DevOps Agent or Kiro の使いどころを考える_20260402
masakiokuda
0
150
不確実性と戦いながら見積もりを作成するプロセス/mitsumori-process
hirodragon112
1
180
互換性のある(らしい)DBへの移行など考えるにあたってたいへんざっくり
sejima
PRO
0
540
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
140
Producing Creativity
orderedlist
PRO
348
40k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.4k
Side Projects
sachag
455
43k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The SEO identity crisis: Don't let AI make you average
varn
0
430
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
340
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
320
Designing Experiences People Love
moore
143
24k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
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