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
47
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
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
71
UI Functional Testing
jasonamyers
1
110
Other Decks in Technology
See All in Technology
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
2
660
Master Dataグループ紹介資料
sansan33
PRO
1
4.2k
Next.js 16の新機能 Cache Components について
sutetotanuki
0
210
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
59k
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
110
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
自己管理型チームと個人のセルフマネジメント 〜モチベーション編〜
kakehashi
PRO
5
930
AIエージェントを5分で一気におさらい!AIエージェント「構築」元年に備えよう
yakumo
1
130
田舎で20年スクラム(後編):一個人が企業で長期戦アジャイルに挑む意味
chinmo
1
690
「駆動」って言葉、なんかカッコイイ_Mitz
comucal
PRO
0
130
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
330
2025年のデザインシステムとAI 活用を振り返る
leveragestech
0
660
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.5k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
80
YesSQL, Process and Tooling at Scale
rocio
174
15k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Un-Boring Meetings
codingconduct
0
170
So, you think you're a good person
axbom
PRO
0
1.9k
A Modern Web Designer's Workflow
chriscoyier
698
190k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Darren the Foodie - Storyboard
khoart
PRO
0
2.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Information Architects: The Missing Link in Design Systems
soysaucechin
0
730
Large-scale JavaScript Application Architecture
addyosmani
515
110k
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