Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CLI Tool開発のためのRust
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
niboshi
March 01, 2017
Programming
1.3k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CLI Tool開発のためのRust
2017/03/01 "RustのLT会! Rust入門者の集い #2"で使った資料です。
niboshi
March 01, 2017
Other Decks in Programming
See All in Programming
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
190
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.9k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
150
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.5k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
360
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
570
phperだってパンチカードでコーディングしたい
o0h
PRO
0
240
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
260
APNsからLive Activityを開始する話
yumnumm
0
160
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
510
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
510
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
560
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Six Lessons from altMBA
skipperchong
29
4.5k
Crafting Experiences
bethany
1
380
Bash Introduction
62gerente
615
220k
Visualization
eitanlees
153
17k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
450
Marketing to machines
jonoalderson
1
5.9k
Balancing Empowerment & Direction
lara
6
1.3k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
Transcript
CLI Tool։ൃͷͨΊͷ Rust ʹ΅͠(@mpppk)
Rustೖऀͷू͍(૾) ͢͝ʔ͍ MFUzϨοτzͬͯ ಡΉΜͩΑ ͳΔ΄Ͳ ʔ
Rustೖऀͷू͍(ݱ࣮)
େมͳͱ͜Ζʹདྷͯ͠·ͬͨ (ݫ͍͠ϚαΧϦ͓ئ͍͠·͢ʂ)
ʹ΅͠(@mpppk)
mpppk/skylarq • yamlͰॻ͍ͨ༰ʹ ैͬͯɺϑΝϛϨεͷ Ξϯέʔτʹࣗಈճ ͯ͠ΫʔϙϯΛ͏ CLI Tool(Node.js)
RustͰCLI Tool࡞Γ͍ͨ
RustΛ࢝ΊΔࡍͷ (ͨͿΜ)ҰൠతͳϞνϕʔγϣϯ • ϝϞϦ҆શ • ϦΞϧλΠϜੑ • ϨΠϠʔ৮ΕΔ • WebAssembly
γϡοͱCLI࡞Γ͍ͨͱ͖ʹ Rustྑ͍ͷͰઆ • ΫϩείϯύΠϧ • όΠφϦ1ͭͰಈ࡞ • ϨΠϠʔ৮ΕΔ • Ϧονͳจ๏(iterator,
pattern match, etc…) • ඞཁेͳϥΠϒϥϦ
ྫ͑ jqΫϩʔϯΛ࡞Δͱ͢Δͱ • ඞཁͳͷ • serializer/deserializer • option parser •
query parser
Serialiser / Deserialiser
serializer/deserializer ͷબࢶ • Serde(˒674) • rustc-serialize(˒166) • ࠓޙSerdeʹஔ͖Θ͍ͬͯ͘Β͍͠
Serde • γϦΞϥΠζ/σγϦΞϥΠζͷͨΊͷFW • ҙͷstructʹରͯ͠derive attributeͰ Serialize/Deserialize Trait͕࣮͞ΕΔ • ࣗલͰTraitΛ࣮͢Δ͜ͱͰ֦ுՄೳ
Serde Example: serde_json
SerdeରԠࡁϑΥʔϚοτ
Option Parser
Option parserͷબࢶ • clap-rs(˒947) • ࡉ੍͔͍ޚ͕Մೳ • getopts(˒49) • Rustެࣜ
• ϛχϚϧͳ༷ • docopt.rs(˒452) • cargo͕࠾༻ • ϔϧϓϝοηʔδ͔ΒࣗಈͰparser͕ੜ͞ΕΔ
clap-rs (Option parser) • Builder PatternͰίϚϯυϥΠϯҾΛఆٛ
clap-rs (Option parser) • --help--version͕উखʹ࣮͞ΕΔ
Query Parser
query parserͷબࢶ • nikomatsakis/lalrpop(˒371) • ಠࣗߏจ • Ұ෦ͷsyntax͕௨Βͳ͍ͳͲɺ·ͩൃలத • kevinmehall/rust-peg(˒342)
• ಠࣗߏจ • Geal/nom(˒1212) • parser combinator • byte୯ҐͰͷॲཧ͕Մೳ • RustͷϚΫϩͱͯ͠ఆ͍ٛͯ͘͠
lalrpop (query parser) • parser generator + α • ୯ͳΔߏจͷߏங͚ͩͰͳ͘
۩ମతͳॲཧ༰ҰॹʹఆٛͰ͖Δ
mpppk/aq • ͱΓ͋͑ͣ.fooͷύʔεΛ Ͱ͖ΔΑ͏ʹ͚ͨͩ͠ • ͍ΖΜͳϑΥʔϚοτʹରԠͰ͖Δͱ ศརͦ͏
·ͱΊ • CLI͋Μ·ؔͳ͔ͬͨ • ཉ͍͠ͱࢥͬͨϥΠϒϥϦ͍͍ͩͨ͋Δײ͡ • Rustͷײ • Pattern matchॆ࣮ͨ͠IteratorͷAdapter/Consumer
͕͋ͬͯॻָ͍͍ͯͯ͠ • ͱʹ͔͘ίϯύΠϧ͕௨Βͳ͍ • ϝιουʹΓग़͚ͨͩ͠ͰΤϥʔ • ͱΓ͋͑ͣclone()࿈ଧ… • ࠓ·Ͱҙࣝͯ͠ͳ͔ͬͨΦʔόϔουΛҙࣝͤ͟ΔΛ ಘͳͯ͘ྑ͍ͷ͔
͓ΘΓ