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
6
4k
Platform Engineering at Mercari
tcnksm
8
5.1k
Embedded SRE at Mercari
tcnksm
0
1.5k
How We Harden Platform Security at Mercari
tcnksm
2
1.8k
SRE Practices in Mercari Microservices
tcnksm
11
13k
開発者向けの基盤をつくる
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.6k
Other Decks in Technology
See All in Technology
Enterprise AI in 2025?
pamelafox
0
100
製造業の会計システムをDDDで開発した話
caddi_eng
3
980
大規模サービスにおける カスケード障害
takumiogawa
2
270
30代エンジニアが考える、エンジニア生存戦略~~セキュリティを添えて~~
masakiokuda
4
2k
「ラベルにとらわれない」エンジニアでいること/Be an engineer beyond labels
kaonavi
0
150
RAGの基礎から実践運用まで:AWS BedrockとLangfuseで実現する構築・監視・評価
sonoda_mj
0
440
ウェブアクセシビリティとは
lycorptech_jp
PRO
0
280
20250328_RubyKaigiで出会い鯛_____RubyKaigiから始まったはじめてのOSSコントリビュート.pdf
mterada1228
0
130
SpannerとAurora DSQLの同時実行制御の違いに想いを馳せる
masakikato5
0
570
Agile TPIを活用した品質改善事例
tomasagi
0
340
ソフトウェアプロジェクトの成功率が上がらない原因-「社会価値を考える」ということ-
ytanaka5569
0
130
Riverpod & Riverpod Generatorを利用して状態管理部分の処理を書き換えてみる簡単な事例紹介
fumiyasac0921
0
110
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
12
1.4k
A better future with KSS
kneath
238
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
8
700
Practical Orchestrator
shlominoach
187
10k
Adopting Sorbet at Scale
ufuk
75
9.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
For a Future-Friendly Web
brad_frost
176
9.6k
GraphQLの誤解/rethinking-graphql
sonatard
70
10k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.4k
Building Adaptive Systems
keathley
41
2.5k
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