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
49k
コマンドラインツールについて語るときに僕の語ること #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
4.5k
Platform Engineering at Mercari
tcnksm
8
5.3k
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
ドキュメントはAIの味方!スタートアップのアジャイルを加速するADR
kawauso
3
220
mruby(PicoRuby)で ファミコン音楽を奏でる
kishima
1
160
知られざるprops命名の慣習 アクション編
uhyo
10
2.3k
OpenAPIから画面生成に挑戦した話
koinunopochi
0
150
Autonomous Database Serverless 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
18
52k
20250818_KGX・One Hokkaidoコラボイベント
tohgeyukihiro
0
130
Backboneとしてのtimm2025
yu4u
3
1.3k
GCASアップデート(202506-202508)
techniczna
0
240
新卒(ほぼ)専業Kagglerという選択肢
nocchi1
1
1.9k
[OCI Skill Mapping] AWSユーザーのためのOCI(2025年8月20日開催)
oracle4engineer
PRO
2
130
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.6k
Understanding Go GC #coefl_go_jp
bengo4com
0
1.1k
Featured
See All Featured
Six Lessons from altMBA
skipperchong
28
4k
Balancing Empowerment & Direction
lara
2
580
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
How to Think Like a Performance Engineer
csswizardry
25
1.8k
Side Projects
sachag
455
43k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Building an army of robots
kneath
306
46k
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