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
Building CLI with Swift
Search
Oleksandr Voronov
March 19, 2016
Programming
1
310
Building CLI with Swift
https://youtu.be/5h-l_ou95_o
Oleksandr Voronov
March 19, 2016
Tweet
Share
More Decks by Oleksandr Voronov
See All by Oleksandr Voronov
Controllable Randomness in Unit Tests
alexandervoronov
1
37
Modularizing your iOS apps
alexandervoronov
0
120
TDD in Real World
alexandervoronov
1
210
Stanfy MadCode 10: From Java to Kotlin, from Objective-C to Swift
alexandervoronov
0
220
Alexander Voronov
alexandervoronov
2
1.2k
ReactiveCocoa
alexandervoronov
0
140
Other Decks in Programming
See All in Programming
命名をリントする
chiroruxx
1
390
103 Early Hints
sugi_0000
1
230
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
useSyncExternalStoreを使いまくる
ssssota
6
1k
MCP with Cloudflare Workers
yusukebe
2
220
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
110
良いユニットテストを書こう
mototakatsu
5
2k
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
710
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Optimizing for Happiness
mojombo
376
70k
The Language of Interfaces
destraynor
154
24k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Speed Design
sergeychernyshev
25
670
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Side Projects
sachag
452
42k
Making the Leap to Tech Lead
cromwellryan
133
9k
A designer walks into a library…
pauljervisheath
204
24k
A better future with KSS
kneath
238
17k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Transcript
IT Saturday • @aleks_voronov • Stanfy BUILDING CLI WITH SWIFT
ALEXANDER VORONOV, STANFY @aleks_voronov
IT Saturday • @aleks_voronov • Stanfy REASON WHY?
IT Saturday • @aleks_voronov • Stanfy OTHER PLATFORMS
IT Saturday • @aleks_voronov • Stanfy JAVASCRIPT NODEJS NPM BOWER
GULP GRUNT
IT Saturday • @aleks_voronov • Stanfy RUBY RACK RAILS SINATRA
RUBYGEMS RAKE
IT Saturday • @aleks_voronov • Stanfy PYTHON PYPI PIP …
IT Saturday • @aleks_voronov • Stanfy SWIFT COCOAPODS CARTHAGE SPM
PERFECT COMMANDANT
IT Saturday • @aleks_voronov • Stanfy FULLSTACK MULTIPLATFORM
IT Saturday • @aleks_voronov • Stanfy FULLSTACK MULTIPLATFORM
IT Saturday • @aleks_voronov • Stanfy WHAT IS CLI?
IT Saturday • @aleks_voronov • Stanfy WHAT IS CLI?
IT Saturday • @aleks_voronov • Stanfy CLI ARGUMENTS
IT Saturday • @aleks_voronov • Stanfy POSIX STANDARD SHORT FLAGS
$ ls -a $ ruby -v $ git commit -m "..."
IT Saturday • @aleks_voronov • Stanfy GNU STANDARD LONG FLAGS
$ ls --all $ ruby --version $ git commit --message "..."
IT Saturday • @aleks_voronov • Stanfy COMBINED FLAGS $ git
commit -a -m "..." $ git commit -am "..."
IT Saturday • @aleks_voronov • Stanfy SUBCOMMANDS $ git log
-2 $ git status $ git commit -am "..."
IT Saturday • @aleks_voronov • Stanfy STANDARD IO 0 -
STDIN 1 - STDOUT 2 - STDERR
IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1
- STDOUT 2 - STDERR $ cat nofile > cat: nofile: No such file or directory
IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1
- STDOUT 2 - STDERR $ cat nofile 2>>err.log
IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1
- STDOUT 2 - STDERR $ cat nofile 2>&1
IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1
- STDOUT 2 - STDERR $ cat nofile 2>>err.log 1>>out.log
IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1
- STDOUT 2 - STDERR $ cat nofile 2>/dev/null
IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1
- STDOUT 2 - STDERR $ cat nofile 2>&1 | grep kernel
IT Saturday • @aleks_voronov • Stanfy UNIX PIPELINES ⛓ $
ls -l | grep "Mar" | sort
IT Saturday • @aleks_voronov • Stanfy UNIX PIPELINES ⛓ $
ps aux | grep Xcode | awk '{print $2}'
IT Saturday • @aleks_voronov • Stanfy UNIX PIPELINES ⛓ $
git branch | xargs git branch -D
IT Saturday • @aleks_voronov • Stanfy CLI WITH SWIFT
IT Saturday • @aleks_voronov • Stanfy SWIFT REPL (READ-EVALUATION-PRINT-LOOP) $
swift
IT Saturday • @aleks_voronov • Stanfy IMMEDIATE MODE $ swift
script.swift
IT Saturday • @aleks_voronov • Stanfy SWIFT COMPILE ⚙ $
swiftc script.swift $ ./script
IT Saturday • @aleks_voronov • Stanfy SWIFT COMPILE ⚙ $
swiftc script.swift -o myscript $ ./myscript
IT Saturday • @aleks_voronov • Stanfy EXECUTABLE SCRIPTS
IT Saturday • @aleks_voronov • Stanfy EXECUTABLE SCRIPTS #!/USR/BIN/SWIFT HASHBANG
IT Saturday • @aleks_voronov • Stanfy EXECUTABLE SCRIPTS CHMOD +X
SCRIPT.SWIFT
IT Saturday • @aleks_voronov • Stanfy SCALING OUR CLI WORKING
WITH MULTIPLE FILES
IT Saturday • @aleks_voronov • Stanfy MAIN.SWIFT
IT Saturday • @aleks_voronov • Stanfy EXECUTING MULTIPLE FILES $
swift main.swift script.swift
IT Saturday • @aleks_voronov • Stanfy $ swiftc main.swift script.swift
-o script EXECUTING MULTIPLE FILES
IT Saturday • @aleks_voronov • Stanfy $ swiftc script.swift main.swift
-o script EXECUTING MULTIPLE FILES
IT Saturday • @aleks_voronov • Stanfy $ swiftc *.swift -o
script EXECUTING MULTIPLE FILES
IT Saturday • @aleks_voronov • Stanfy $ find . -iname
'*.swift' | xargs swiftc -o script EXECUTING MULTIPLE FILES
IT Saturday • @aleks_voronov • Stanfy EXTERNAL RESOURCES
IT Saturday • @aleks_voronov • Stanfy SYSTEM DEPENDENCIES $ swiftc
script.swift $ xcrun -sdk macosx swiftc script.swift
IT Saturday • @aleks_voronov • Stanfy CUSTOM DEPENDENCIES -F $
swift -F /Carthage/Build/Mac script.swift
IT Saturday • @aleks_voronov • Stanfy CUSTOM DEPENDENCIES #!/USR/BIN/SWIFT -F
Carthage/Build/Mac HASHBANG
IT Saturday • @aleks_voronov • Stanfy COMPILING DEPENDENT SCRIPT
IT Saturday • @aleks_voronov • Stanfy $ xcrun \ -sdk
macosx swiftc \ -F Carthage/Build/Mac script.swift COMPILING DEPENDENT SCRIPT > dyld: Library not loaded: @rpath
IT Saturday • @aleks_voronov • Stanfy $ xcrun \ -sdk
macosx swiftc \ -F Carthage/Build/Mac script.swift \ -Xlinker -rpath \ -Xlinker @executable_path/Carthage/Build/Mac COMPILING DEPENDENT SCRIPT
IT Saturday • @aleks_voronov • Stanfy DEPENDENCIES MANAGEMENT
IT Saturday • @aleks_voronov • Stanfy COCOAPODS
IT Saturday • @aleks_voronov • Stanfy CARTHAGE
IT Saturday • @aleks_voronov • Stanfy SPM SWIFT PACKAGE MANAGER
IT Saturday • @aleks_voronov • Stanfy PARSING ARGUMENTS
IT Saturday • @aleks_voronov • Stanfy PARSING ARGUMENTS $ ./script
one two three $ ./script one\ two\ three $ ./script "one two three" 3 args 1 arg 1 arg
IT Saturday • @aleks_voronov • Stanfy PROCESS ENUM Process.arguments ==
[ "./script.swift", "one", "two", "three" ]
IT Saturday • @aleks_voronov • Stanfy FILESYSTEM
IT Saturday • @aleks_voronov • Stanfy FILESYSTEM NSFILEMANAGER NSFILEHANDLER NSTASK
NSPIPE
IT Saturday • @aleks_voronov • Stanfy HANDY LIBRARIES COMMANDER OPTIONKIT
COMMANDANT REACTIVETASKS PRETTYCOLORS
IT Saturday • @aleks_voronov • Stanfy REAL WORLD EXAMPLES CARTHAGEKIT
CARTHAGE CLI
IT Saturday • @aleks_voronov • Stanfy THANK YOU!
IT Saturday • @aleks_voronov • Stanfy Q/A @ALEKS_VORONOV A-VORONOV