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
コマンドラインツールについて語るときに僕の語ること #yapcasia
Search
taichi nakashima
August 29, 2014
Technology
120
48k
コマンドラインツールについて語るときに僕の語ること #yapcasia
http://yapcasia.org/2014/talk/show/b49cc53a-027b-11e4-9357-07b16aeab6a4
taichi nakashima
August 29, 2014
Tweet
Share
More Decks by taichi nakashima
See All by taichi nakashima
Platform Engineering at Mercari (Platform Engineering Kaigi 2024)
tcnksm
5
3.6k
Platform Engineering at Mercari
tcnksm
8
4.8k
Embedded SRE at Mercari
tcnksm
0
1.4k
How We Harden Platform Security at Mercari
tcnksm
2
1.7k
SRE Practices in Mercari Microservices
tcnksm
11
12k
開発者向けの基盤をつくる
tcnksm
38
12k
How We Structure Our Work At Mercari Microservices Platform Team
tcnksm
11
23k
Microservices Platform on Kubernetes at Mercari
tcnksm
16
16k
Introduction to Mercari Micorservices Platform Team
tcnksm
5
3.5k
Other Decks in Technology
See All in Technology
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
520
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
100
複雑性の高いオブジェクト編集に向き合う: プラガブルなReactフォーム設計
righttouch
PRO
0
110
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
Postman と API セキュリティ / Postman and API Security
yokawasa
0
200
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
AIのコンプラは何故しんどい?
shujisado
1
190
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
0
280
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
370
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Practical Orchestrator
shlominoach
186
10k
The World Runs on Bad Software
bkeepers
PRO
65
11k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Statistics for Hackers
jakevdp
796
220k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
A designer walks into a library…
pauljervisheath
204
24k
Why Our Code Smells
bkeepers
PRO
335
57k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Gamification - CAS2011
davidbonilla
80
5.1k
Transcript
What I Talk about When I Talk about CLI Tool
ίϚϯυϥΠϯπʔϧʹ͍ͭͯޠΔͱ͖ʹͷޠΔ͜ͱ https://www.flickr.com/photos/36247316@N00/3108399560
I’m Taichi Nakashima @deeeet tcnksm https://www.flickr.com/photos/flcherb/7781533580
https://www.flickr.com/photos/flcherb/7781533580
https://www.flickr.com/photos/flcherb/7781533580
https://www.flickr.com/photos/flcherb/7781533580
What I Talk about When I Talk about CLI Tool
ίϚϯυϥΠϯπʔϧʹ͍ͭͯޠΔͱ͖ʹͷޠΔ͜ͱ https://www.flickr.com/photos/36247316@N00/3108399560
ຊൃදʹݸਓతͳࢥؚ͕·Ε͍ͯ·͢ Warning https://www.flickr.com/photos/flcherb/7781533580
ຊൃදʹPerlͷؚ͕·Ε͍ͯ·ͤΜ Warning ͨͩɼ͋ΒΏΔݴޠͰ࣮ݱՄೳͳΛ͠·͢ https://www.flickr.com/photos/flcherb/7781533580
Background https://www.flickr.com/photos/flcherb/7781533580
https://www.flickr.com/photos/flcherb/7781533580 ੈͷதʹ ྑ͍$-*πʔϧͱ ͦ͏Ͱͳ͍πʔϧ͕͋Δ
https://www.flickr.com/photos/flcherb/7781533580 ͦͷࠩ୯७ͳ͜ͱΛ ࣮ફ͢Δ͜ͱͰॖΊΔ ͜ͱ͕Ͱ͖Δ ͨΓલա͗ͯ͋·ΓޠΒΕͳ͍
https://www.flickr.com/photos/flcherb/7781533580 ࣗԿΛ࣮ફ͍ͯ͠Δ͔ʁ
طʹ࡞͍ͬͯΔͻͱ https://www.flickr.com/photos/flcherb/7781533580 ࡞ͬͨ͜ͱͳ͍ͻͱ → ݟ͠ͷػձʹ → ͙͢ʹΤσΟλΛ։͚ΔΑ͏ʹ
lྑ͍z$-*πʔϧͱʁ ͍͔ʹlྑ͍z$-*πʔϧΛ࡞Γ࢝ΊΔ͔ʁ What is “Good” CLI tool ? How to
start to create “Good” CLI tool ? https://www.flickr.com/photos/36247316@N00/3108399560
lྑ͍z$-*πʔϧͱʁ ͍͔ʹlྑ͍z$-* What is “Good” CLI tool ? How to
start to create “Good” CLI tool ? https://www.flickr.com/photos/36247316@N00/3108399560
#1 ͭͷ͜ͱʹूத͍ͯ͠Δ ײతʹ͑Δ ଞͷπʔϧͱ࿈ܞͰ͖Δ ར༻Λॿ͚ͯ͘ΕΔ దͳσϑΥϧτΛ࣋ͪઃఆͰ͖Δ ۤ௧ͳ͘ΠϯετʔϧͰ͖Δ ͙͢ʹվमͰ͖Δ #2 #3
#4 #5 #6 #7 https://www.flickr.com/photos/36247316@N00/3108399560
Good CLI Tool #1 Keep It Simple, Stupid ! ͭͷ͜ͱʹूத͍ͯ͠Δ
https://www.flickr.com/photos/110382334@N05/11302995614
https://www.flickr.com/photos/110382334@N05/11302995614
খ͍͞ͷඒ͍͠ 4NBMMJTCFBVUJGVM ͭͷϓϩάϥϜʹ ͭͷ͜ͱΛ͏·͘ΒͤΔ .BLFFBDIQSPHSBNEPPOFUIJOHXFMM https://www.flickr.com/photos/110382334@N05/11302995614
https://www.flickr.com/photos/110382334@N05/11302995614 ̎ͭҎ্ͷ͜ͱΛΖ͏ͱ ͢Δ͚ͩͰෳࡶ૿͢ ཧղͰ͖ͳ͍ɾशಘͰ͖ͳ͍ ϝϯςφϯεͰ͖ͳ͍
Good CLI Tool #2 Intuitive UI/UX ײతʹ͑Δ https://www.flickr.com/photos/hindrik/5568789280
$-*πʔϧʹ6*69 $-*πʔϧͷྺ࢙͍ ׳श͕ଘࡏ͢Δ https://www.flickr.com/photos/hindrik/5568789280
Command Pattern https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp &YFDVUBCMF https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp &YFDVUBCMF 0QUJPOT
https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp &YFDVUBCMF 0QUJPOT
"SHVNFOUT https://www.flickr.com/photos/hindrik/5568789280
> git --no-pager push -v origin master https://www.flickr.com/photos/hindrik/5568789280
> git --no-pager push -v origin master &YFDVUBCMF https://www.flickr.com/photos/hindrik/5568789280
> git --no-pager push -v origin master &YFDVUBCMF $PNNBOE https://www.flickr.com/photos/hindrik/5568789280
> git --no-pager push -v origin master &YFDVUBCMF (MPCBM 0QUJPOT
$PNNBOE https://www.flickr.com/photos/hindrik/5568789280
> git --no-pager push -v origin master &YFDVUBCMF (MPCBM 0QUJPOT
$PNNBOE $PNNBOE 0QUJPOT https://www.flickr.com/photos/hindrik/5568789280
> git --no-pager push -v origin master &YFDVUBCMF (MPCBM 0QUJPOT
$PNNBOE $PNNBOE 0QUJPOT "SHVNFOUT https://www.flickr.com/photos/hindrik/5568789280
Option Pattern https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp 4XJUDI ҾΛΘͳ͍
https://www.flickr.com/photos/hindrik/5568789280
> grep —i -C 4 "some string" /tmp 4XJUDI ҾΛΘͳ͍
'MBH ҾΛ͏ https://www.flickr.com/photos/hindrik/5568789280
> grep —i > grep --ignore-case https://www.flickr.com/photos/hindrik/5568789280
> grep —i > grep --ignore-case 4IPSU ߴʹ͏ͨΊʹ https://www.flickr.com/photos/hindrik/5568789280
> grep —i > grep --ignore-case 4IPSU -POH ߴʹ͏ͨΊʹ ՄಡੑΛߴΊΔ
https://www.flickr.com/photos/hindrik/5568789280
(/6ඪ४ΠϯλʔϑΣʔε cf. https://www.gnu.org/prep/standards/html_node/ Command_002dLine-Interfaces.html https://www.flickr.com/photos/hindrik/5568789280
https://www.flickr.com/photos/hindrik/5568789280 My Interface design
https://www.flickr.com/photos/hindrik/5568789280 ࠷Γ͍ͨ͜ͱΛ࠷؆୯ʹ Φϓγϣϯ͕ඞཁͳΒShortΦϓγϣϯΛ४උ͢Δ σϑΥϧτͰഁյతૢ࡞Λ͠ͳ͍ ରΠϯλʔϑΣʔεΛආ͚Δ LongΦϓγϣϯΛ४උ͢Δ e.g., —force ࣗಈԽͷ͛ʹͳΔ
Good CLI Tool #3 Play well with others ଞͷπʔϧͱ࿈ܞͰ͖Δ https://www.flickr.com/photos/alexsk/3251194325
$-*πʔϧଞͷεΫϦϓτ ͔Βݺͼग़͞ΕΔ 4IFMMTDSJQU$SPO $IFG %PDLFSpMF https://www.flickr.com/photos/alexsk/3251194325
Exit Code https://www.flickr.com/photos/alexsk/3251194325
exit 0 exit 1 nonzero ޭ ࣦഊ https://www.flickr.com/photos/alexsk/3251194325
Output Stream https://www.flickr.com/photos/alexsk/3251194325
stdout stderr Τϥʔϝοηʔδ ϑΝΠϧʹॻ͖ग़͍ͨ͠ ύΠϓͰ͍ͨ͠ https://www.flickr.com/photos/alexsk/3251194325 ඪ४Τϥʔ ඪ४
Good CLI Tool #4 Documentation ར༻Λॿ͚ͯ͘ΕΔ https://www.flickr.com/photos/jjpacres/3293117576
υΩϡϝϯτ6TBHF͕ ଘࡏ͠ͳ͍πʔϧͳͲ ୭͍ͨ͘ͳ͍ ར༻ʹ߹ΘͤͨυΩϡϝϯτΛ४උ͢Δ https://www.flickr.com/photos/jjpacres/3293117576
Document Pattern https://www.flickr.com/photos/jjpacres/3293117576
ར༻ස https://www.flickr.com/photos/jjpacres/3293117576
ར༻ස 3&"%.&NE ͏͔൱͔Λஅ͢Δ https://www.flickr.com/photos/jjpacres/3293117576
ར༻ස 3&"%.&NE 6TBHF ͏͔൱͔Λஅ͢Δ πʔϧΛಈ͔ͨ͢Ίʹ ࠷ݶΔ͖ ͍ํΛཧղ͢Δ IFMQI https://www.flickr.com/photos/jjpacres/3293117576
ར༻ස 3&"%.&NE 6TBHF .BO ͏͔൱͔Λஅ͢Δ πʔϧΛಈ͔ͨ͢Ίʹ ࠷ݶΔ͖ ͍ํΛཧղ͢Δ ෳࡶͳྫ ΑΓॊೈʹ͏ͨΊ
ͷΦϓγϣϯΛൃݟ͢Δ IFMQI https://www.flickr.com/photos/jjpacres/3293117576
Good CLI Tool #5 Configurable దͳσϑΥϧτΛ࣋ͪ ઃఆͰ͖Δ https://www.flickr.com/photos/dwilkin/12153072866
ϢʔβʹແବͳೖྗΛ ͤ͞ͳ͍ https://www.flickr.com/photos/dwilkin/12153072866
ϢʔβʹແବͳೖྗΛ ͤ͞ͳ͍ ͕ ͖ʹઃఆͰ͖Δ https://www.flickr.com/photos/dwilkin/12153072866 શһΛຬͤ͞Δ͜ͱͰ͖ͳ͍
Configuration Pattern https://www.flickr.com/photos/dwilkin/12153072866
༏ઌ https://www.flickr.com/photos/dwilkin/12153072866
༏ઌ σϑΥϧτ https://www.flickr.com/photos/dwilkin/12153072866
༏ઌ σϑΥϧτ ઃఆϑΝΠϧ ਓ͕ؒಡΊΔͷ(json/YAML/DSL/HCL) https://www.flickr.com/photos/dwilkin/12153072866
༏ઌ σϑΥϧτ ઃఆϑΝΠϧ ڥม ਓ͕ؒಡΊΔͷ(json/YAML/DSL/HCL) https://www.flickr.com/photos/dwilkin/12153072866
༏ઌ σϑΥϧτ ઃఆϑΝΠϧ ڥม ΦϓγϣϯҾ ਓ͕ؒಡΊΔͷ(json/YAML/DSL/HCL) https://www.flickr.com/photos/dwilkin/12153072866
Good CLI Tool #6 Painless Installation ۤ௧ͳ͘ΠϯετʔϧͰ͖Δ https://www.flickr.com/photos/midorisyu/752223850
ରϢʔβʹ߹ͬͨ Πϯετʔϧํ๏ .BDϢʔβʹʁ1FSMϢʔβʹʁ https://www.flickr.com/photos/midorisyu/752223850
1 Command Install https://www.flickr.com/photos/midorisyu/752223850
> brew install > apt-get install > yum install >
cpan > gem install > pip install https://www.flickr.com/photos/midorisyu/752223850
Good CLI Tool #7 maintainable ͙͢ʹվमͰ͖Δ https://www.flickr.com/photos/damski/7045068945
ΤϥʔඞͣىΔ ى͖ͨͱ͖ʹԿ͕ىͬͯΔ͔ ৄࡉ͕֬ೝͰ͖Δ ιʔεΛݟͣʹԿ͕ىͬͯΔ͔Θ͔Δ ιʔεͷͲ͜ΛͤΑ͍͔Θ͔Δ https://www.flickr.com/photos/damski/7045068945
DEBUG Option https://www.flickr.com/photos/damski/7045068945
> tool --debug Φϓγϣϯ https://www.flickr.com/photos/damski/7045068945
> tool --debug > export DEBUG=1 > tool Φϓγϣϯ ڥม
։ൃऀ͚ https://www.flickr.com/photos/damski/7045068945
#1 ͭͷ͜ͱʹूத͍ͯ͠Δ ײతʹ͑Δ ଞͷπʔϧͱ࿈ܞͰ͖Δ ར༻Λॿ͚ͯ͘ΕΔ దͳσϑΥϧτΛ࣋ͪઃఆͰ͖Δ ۤ௧ͳ͘ΠϯετʔϧͰ͖Δ ͙͢ʹվमͰ͖Δ #2 #3
#4 #5 #6 #7 https://www.flickr.com/photos/36247316@N00/3108399560
lྑ͍z$-* ͍͔ʹlྑ͍z$-*πʔϧΛ࡞Γ࢝ΊΔ͔ʁ What How to start to create “Good” CLI
tool ? https://www.flickr.com/photos/36247316@N00/3108399560
#1 ͲΜͳπʔϧΛ࡞Δ͔ߟ͑Δ ݴޠΛબͿ 3&"%.&NEΛॻ͘ #2 #3 https://www.flickr.com/photos/36247316@N00/3108399560 ߴʹϓϩτλΠϓΛͭ͘Δ %&.0 #4
How to start #1 Chance ͲΜͳπʔϧΛ࡞Δ͔ߟ͑Δ https://www.flickr.com/photos/cleopold73/3677296594
$-*πʔϧͷ ॳظিಈ ෳࡶͳ࡞ۀΛࣗಈԽ͍ͨ͠ ͋ΔλεΫͷੜ࢈ੑΛߴΊ͍ͨ "1*ͷ$-*ΫϥΠΞϯτཉ͍͠ ʜ https://www.flickr.com/photos/cleopold73/3677296594
͍͖ͳΓෳࡶͳ͜ͱΛ͠ͳ͍ ! ͭͷ͜ͱʹूத͢Δ Good CLI Tool #1 https://www.flickr.com/photos/cleopold73/3677296594
ͷҰ෦Λղܾ͢Δ͚ͩͰΑ͍ ! ଞͷπʔϧͱ࿈ܞͰ͖Δ Α͏ʹ͢Δ Good CLI Tool #3 https://www.flickr.com/photos/cleopold73/3677296594
How to start #2 Programming language ݴޠΛબͿ https://www.flickr.com/photos/8153468@N04/2668229310
ݴޠબ πʔϧͷํ๏ʹ݁͢Δ ! ۤ௧ͳ͘Πϯετʔϧ ͯ͠Β͏͜ͱΛߟ͑Δ Good CLI Tool #6 https://www.flickr.com/photos/8153468@N04/2668229310
(P ͋ΒΏΔϓϥοτϑΥʔϜ ͷϢʔβΛରʹ 1FSM Perl mongerΛରʹ SVCZ rubyistΛରʹ https://www.flickr.com/photos/8153468@N04/2668229310 ˠόΠφϦμϯϩʔυͰ
ˠHFNͰ ˠDQBOͰ
How to start #3 README Driven Development 3&"%.&NEΛॻ͘ https://www.flickr.com/photos/alessiorr/14144160337
README Driven Development https://www.flickr.com/photos/alessiorr/14144160337
ίʔυΛॻ͘લʹ 3&"%.&NEΛॻ͘ ໊લΛߟ͑Δɼ $-*πʔϧ͕ԿΛ͢Δͷͳͷ͔Λߟ͑Δɼ $-*πʔϧͷΠϯλʔϑΣʔε ͍ํ Λߟ͑Δ https://www.flickr.com/photos/alessiorr/14144160337
͕ࣗԿΛ࡞Γ͍ͨͷ͔ ཧ্ͨ͠Ͱ࡞Γ࢝ΊΒΕΔ https://www.flickr.com/photos/alessiorr/14144160337
None
ϢʔβࢹͰσβΠϯͰ͖Δ https://www.flickr.com/photos/alessiorr/14144160337
൪ςϯγϣϯ͕ߴ͍ͱ͖ʹ υΩϡϝϯτ͕ॻ͚Δ ࡞ΓऴΘͬͨޙʹυΩϡϝϯτΛඋ͢Δ ͷ͠ΜͲ͍ʜ https://www.flickr.com/photos/alessiorr/14144160337
NAME ==== ! ## Description ! ## Usage ! ##
VS. https://www.flickr.com/photos/alessiorr/14144160337
ස͕ߴ͍ͳΒͰ͖Δ͚ͩ ໊͍લΛ͚Δ ස͕͍ͳΒ આ໌తͳ໊લΛ͚Δ = ίϚϯυ໊ NAME ==== ! ##
Description ! ## Usage ! ## VS. ໊લ https://www.flickr.com/photos/alessiorr/14144160337
͜ΕͲΜͳπʔϧͳͷ͔ʁ ͭͷ͜ͱʹूத͍ͯ͠Δ Good CLI Tool #1 = ͘؆ܿͳઆ໌͕ॻ͚Δ NAME ====
! ## Description ! ## Usage ! ## VS. આ໌ https://www.flickr.com/photos/alessiorr/14144160337
ΠϯλʔϑΣʔεͷఆٛ ײతʹ͑Δ Good CLI Tool #2 ϢʔβͷࢹͰ ࠷Β͍ͤͨ͜ͱΛ ࠷؆୯ʹͰ͖ΔΑ͏ʹ NAME
==== ! ## Description ! ## Usage ! ## VS. ͍ํ https://www.flickr.com/photos/alessiorr/14144160337
ൺֱ ଞͷπʔϧͱͷൺֱ NAME ==== ! ## Description ! ## Usage
! ## VS. ࣅͨΑ͏ͳπʔϧଘࡏ͢Δ શ͘ಉ͡ͷΛ࡞ͬͯ ҙຯͳ͍ ࣅͨπʔϧͱൺͯ! Կ͕༏Ε͍ͯΔͷ͔Λߟ͑Δ! → πʔϧͷಛʹͳΔ https://www.flickr.com/photos/alessiorr/14144160337
όοδ όοδͷ४උ = CI as a Service ͷઃఆ = ͡Ί͔ΒςετڥΛ!
४උ͢Δ ςετ݁ՌΛϢʔβʹ ݟͤଓ͚Δ͜ͱͰ ςετΛॻ͘Ϟνϕʔγϣϯ Λอͪଓ͚Δ NAME ==== ! ## Description ! ## Usage ! ## VS. https://www.flickr.com/photos/alessiorr/14144160337
https://www.flickr.com/photos/sergiu_bacioiu/4664215911 How to start #4 ߴʹϓϩτλΠϓΛ࡞Δ Build a prototype as
soon as possible
https://www.flickr.com/photos/sergiu_bacioiu/4664215911
https://www.flickr.com/photos/sergiu_bacioiu/4664215911
LIVE https://www.flickr.com/photos/sergiu_bacioiu/4664215911
(PݴޠΛͬͯ $-*πʔϧΛ࡞ɼ ΫϩείϯύΠϧͯ͠ (JUIVCʹϦϦʔεʂ https://www.flickr.com/photos/sergiu_bacioiu/4664215911
(PݴޠΛͬͯ $-*πʔϧΛ࡞ɼ ΫϩείϯύΠϧͯ͠ (JUIVCʹϦϦʔεʂ https://www.flickr.com/photos/sergiu_bacioiu/4664215911 tcnksm/cli-init mitchellh/gox tcnksm/ghr codegansta/cli
#1 ͭͷ͜ͱʹूத͍ͯ͠Δ ײతʹ͑Δ ଞͷπʔϧͱ࿈ܞͰ͖Δ ར༻Λॿ͚ͯ͘ΕΔ దͳσϑΥϧτΛ࣋ͪઃఆͰ͖Δ ۤ௧ͳ͘ΠϯετʔϧͰ͖Δ ͙͢ʹվमͰ͖Δ #2 #3
#4 #5 #6 #7 https://www.flickr.com/photos/36247316@N00/3108399560
#1 ͲΜͳπʔϧΛ࡞Δ͔ߟ͑Δ ݴޠΛબͿ 3&"%.&NEΛॻ͘ #2 #3 https://www.flickr.com/photos/36247316@N00/3108399560 ߴʹϓϩτλΠϓΛͭ͘Δ %&.0 #4