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
JSON をそこそこ見やすくする CUI ツールを Objective-C で作ったときの話
Search
griffin-stewie
June 01, 2013
Technology
1
570
JSON をそこそこ見やすくする CUI ツールを Objective-C で作ったときの話
第50回 Cocoa勉強会関西 - iOS/Macアプリ開発勉強会
発表資料
griffin-stewie
June 01, 2013
Tweet
Share
More Decks by griffin-stewie
See All by griffin-stewie
How I develop a Sketch Native Plugin
griffin_stewie
0
660
Boost your App Dev using Sketch
griffin_stewie
0
290
Take a peep at .app
griffin_stewie
0
420
Lightweight Markup Language to PDF
griffin_stewie
1
550
ドキュメント作成どうしてる?
griffin_stewie
0
570
Pitfalls of PhotoKit
griffin_stewie
0
240
Talk about "clg" color list generator.
griffin_stewie
1
430
Tips for Apple Watch.
griffin_stewie
0
780
Other Decks in Technology
See All in Technology
私はこうやってマインドマップでテストすることを出す!
mineo_matsuya
0
250
End of Barrel Files: New Modularization Techniques with Sheriff
rainerhahnekamp
0
280
Platform Engineering ことはじめ
oracle4engineer
PRO
8
810
軽量DDDはもういらない! スタイルガイド本で OOPの実装パターンを学ぼう
panda_program
29
11k
ライブラリでしかお目にかかれない珍しい実装
mikanichinose
2
340
マルチモーダルデータ基盤の課題と観点
neonankiti
1
110
3次元点群データ「VIRTUAL SHIZUOKA』のオープンデータ化による恩恵と協働の未来/FOSS4G Japan 2024
kazz24s
0
130
mikroBus HAT を用いた簡易ベアメタル開発
tarotene
0
270
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
0
160
音声×Copilot オンコパの世界
kasada
1
110
Terraform Stacks入門 #HashiTalks
msato
0
280
データの信頼性を支える仕組みと技術
chanyou0311
6
1.7k
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Adopting Sorbet at Scale
ufuk
73
9.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Happy Clients
brianwarren
97
6.7k
Navigating Team Friction
lara
183
14k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Faster Mobile Websites
deanohume
305
30k
Building Applications with DynamoDB
mza
90
6.1k
Facilitating Awesome Meetings
lara
49
6.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Transcript
JSON Λͦͦ͜͜ݟ͘͢͢Δ CUI πʔϧΛ࡞ͬͨͱ͖ͷ @griffin_stewie 136݄1༵
ࣗݾհ •େࡕͰ iOS ΞϓϦ։ൃͷࣄΛ͍ͯ͠ ·͢ •Cocoa ྺ 5 ఔ •SafariGestures
ͱ͔ SafariTabMemento ͱ ͔ Safari ͷ SIMBL ϓϥάΠϯΛ @canberland ͱҰॹʹ࡞ͬͯ·ͨ͠ɻ 136݄1༵
ຊ 136݄1༵
CUI ͱ 136݄1༵
•Character •User •Interface 136݄1༵
ࠇ͍ը໘ʹढจ 136݄1༵
ී௨ LL ܥݴޠͰαΫοͱ࡞ Δײ͡ 136݄1༵
Ͱɺ 136݄1༵
•Ruby Ҏ֎͞Θͬͨ͜ͱͳ͍ •֎෦ϥΠϒϥϦΛಉࠝͯ͠Ͱ͖ Δͷʁ •ௐΔͷΊΜͲ͍͘͞ •͋͊ ΊΜͲ͍͘͞ 136݄1༵
Ͱɺࣗʹͱͬͯͷ CUI 136݄1༵
•Cocoa Ͱ •U·͍͜ͱΕ •I͍Μ͡ΌͶʁ 136݄1༵
ͯͳΘ͚Ͱ Objective-C Ͱ࡞ͬ ͨͱ͖ͷ 136݄1༵
ಈػ 136݄1༵
JSON ͕ݟʹ͔͔ͬͨ͘Β 136݄1༵
136݄1༵
python -m json.tool 136݄1༵
136݄1༵
ຊޠ͕ಡΊͳ͍ 136݄1༵
࡞ͬͨͷ͕ 136݄1༵
jsonpp http://griffin-stewie.github.io/jsonpp/ 136݄1༵
136݄1༵
ຊޠ͕ಡΊͨ 136݄1༵
•ϩʔΧϧͷ JSON ϑΝΠϧΛಡΈࠐΜ ͩΓ •http Ͱͱ͖ͬͯͨΓ •Key Λιʔτͨ͠Γ •ιʔτ͢Δͱ͖ʹࣈͱͯ͠ѻͬͨΓ •ϑΝΠϧʹอଘͨ͠Γ
136݄1༵
ͬͨ͜ͱ 136݄1༵
ίϚϯυϥΠϯҾͷॲཧͬͯ Ͳ͏Μͷʁ 136݄1༵
•DDCli ͍ͬͯ͏ϥΠϒϥϦΛͬͨ •appledoc ʹΘΕ͍ͯΔ 136݄1༵
•DDCli ͷσϦήʔτϝιουΛ2࣮ͭ͢Δ •1ͭ Φϓγϣϯͷఆٛ༻ • ड͚͚͍ͨίϚϯυϥΠϯΦϓγϣϯΛߏମͷ ྻͱͯ͠ఆٛ •͏1ͭ CUI ΞϓϦͱͯ͠ͷΤϯτϦϙΠϯτ
• ίϚϯυϥΠϯΦϓγϣϯσϦήʔτΦϒδΣΫ τʹ KVC ܦ༝ͰηοτࡁΈ • ͦͷ΄͔ͷҾ͕͞ΕΔ 136݄1༵
1. main.m ͷมߋ int main(int argc, const char * argv[])
{ int result = 0; @autoreleasepool { result = DDCliAppRunWithClass( [CSJSONPrettyPrint class]); } return result; } 136݄1༵
2. Delegate ͷ࣮ •- (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionParser •- (void)application:(DDCliApplication
*)app runWithArguments:(NSArray *)arguments 136݄1༵
•- (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionParser •application:(DDCliApplication *)app runWithArguments:(NSArray *)arguments ͷલʹݺ
ΕΔ •DDGetoptOption ߏମΛ࡞͠ɺσϦήʔτϝ ιουͰ͞Εͨ DDGetoptLongParser Πϯελ ϯεʹ addOptionsFromTable: Ͱ͢ 136݄1༵
DDGetoptOption - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionsParser; { DDGetoptOption optionTable[] =
{ // Long Short Argument options {@"version", 'v', DDGetoptNoArgument}, {@"help", 'h', DDGetoptNoArgument}, {@"output", 'o', DDGetoptRequiredArgument}, {@"filter-key", 'k', DDGetoptRequiredArgument}, {nil, 0, 0}, }; [optionsParser addOptionsFromTable: optionTable]; } 136݄1༵
DDGetoptOption •Long Φϓγϣϯͷ໊শ (--version ͷ "--" Λআ͍ ͨจࣈྻ) •short Φϓγϣϯͷ໊শ
•Φϓγϣϯ͕ҾΛͱΔ͔ͱΒͳ͍͔ͷࢦఆ 136݄1༵
•- (void)application:(DDCliApplication *)app runWithArguments:(NSArray *)arguments •arguments ʹઃఆͨ͠ΦϓγϣϯҎ֎ͷίϚ ϯυϥΠϯҾ͕ೖ͍ͬͯΔ 136݄1༵
ΦϓγϣϯҾͷରԠ •main ؔͰࢦఆͨ͠Ϋϥεʹରͯ͠ KVC Λͬ ͯΛಥͬࠐΜͰ͘ΕΔ • ϓϩύςΟ໊ Long Φϓγϣϯͱಉ໊͡শ
• ܕ NSString 136݄1༵
JSON ͷ Pretty-Print Ͳ͏ͨ͠ͷʁ 136݄1༵
SBJSON ʹؙ͛ 136݄1༵
Debug ΊΜͲͦ͏ 136݄1༵
໘ 136݄1༵
•ͰɺXcode ʹ Run ͨ͠ͱ͖ʹҙ ͷҾΛͤΔΈ͕͋ΔΑ •ෳఆٛͰ͖ͯνΣοΫϘοΫεͰ On/Off Մ •GUI ΞϓϦͱେͯ͠มΘΒͳ͍खؒ
136݄1༵
Xcode ศར 136݄1༵
manpage ࡞ͬͨΑ 136݄1༵
manpage ͷه๏ҙຯෆ໌ 136݄1༵
Կ͜Εʁ จࣈԽ͚ʁ 136݄1༵
͜Μͳͷه๏ͳΜ͔ษڧ ͯ͠ΒΜͶ͐ 136݄1༵
Pandoc Ͱੜͨ͠ 136݄1༵
Pandoc ͬͯʁ •Pandoc a universal document converter • ଟ༷ͳςΩετϑΥʔϚοτΛผͷϑΥʔϚοτʹม •
ରԠϑΥʔϚοτྫ • markdown • reStructuredText • textile • MediaWiki • ODT • docx • ͦͷଞ͍Ζ͍Ζ 136݄1༵
markdown Ͱॻ͍ͯมͨ͠ 136݄1༵
Πϯετʔϥʔ༻ҙͨ͠ 136݄1༵
ࠓͷ Xcode ʹ PackageManager ͕ಉࠝ͞Εͯ ͳ͍ 136݄1༵
Developer Center ͷ Auxiliary Tools for Xcode ͷதʹ͋ͬͨ 136݄1༵
͍ํ؆୯ 136݄1༵
άάΕʂ 136݄1༵
ͱ͍͏͜ͱͰ jsonpp Ͱ͖ͨΑ 136݄1༵
ͰͶ 136݄1༵
jq jq is a lightweight and flexible command-line JSON processor.
136݄1༵
jq •http://stedolan.github.io/jq/ •C Ͱॻ͔Εͨ JSON Λݟͯ͘͘͢͠ΕΔࢠ •ڧྗ •XPath తʹతͷσʔλ͚ͩநग़ͨ͠Γ •map
ͱ͔ select ͱ͔ؔతͳϑΟϧλϦϯά ग़དྷΔ 136݄1༵
͜Μͳͷ͕ 136݄1༵
৭͕͍ͭͨΓ 136݄1༵
ཉ͍͠ͷ͚ͩϑΟϧλͨ͠Γ 136݄1༵
jq Ϛδ Φψψϝ 136݄1༵
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 136݄1༵