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
210
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
78
UI Functional Testing
jasonamyers
1
120
Other Decks in Technology
See All in Technology
AI・ロボティクスと自動化社会 / AI, Robotics, and the Automated Society
ks91
PRO
0
130
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」紹介資料
laysakura
2
7.9k
AI駆動開発におけるQAエンジニアの役割事例 〜AI駆動開発の現場から〜
kobayashiyorimitsu
0
160
product engineering with qa
nealle
0
130
初めてのDatabricks勉強会
taka_aki
2
220
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
230
4人目のSREはAgent
tanimuyk
0
350
攻撃者がいなくてもAIエージェントはインシデントを起こす
nomizone
0
180
Baseline対応のDOMの型定義を作った
uhyo
1
210
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
440
作る力から、見極める力へ — AI時代に広がるエンジニアの価値と役割
rince
0
390
トークン最適化のためのユーザーストーリー分析 / User Story Analysis for Token Optimization
oomatomo
0
160
Featured
See All Featured
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
410
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
We Have a Design System, Now What?
morganepeng
55
8.2k
How STYLIGHT went responsive
nonsquared
100
6.2k
How to train your dragon (web standard)
notwaldorf
97
6.7k
First, design no harm
axbom
PRO
2
1.2k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
880
Practical Orchestrator
shlominoach
191
11k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
340
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