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
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
800
ドメインイベント増えすぎ問題
h0r15h0
2
360
php-conference-japan-2024
tasuku43
0
330
MCP with Cloudflare Workers
yusukebe
2
220
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
Beyond ORM
77web
7
990
선언형 UI에서의 상태관리
l2hyunwoo
0
180
テストコード書いてみませんか?
onopon
2
140
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
780
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
150
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Unsuck your backbone
ammeep
669
57k
Code Review Best Practice
trishagee
65
17k
Visualization
eitanlees
146
15k
The Invisible Side of Design
smashingmag
298
50k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Faster Mobile Websites
deanohume
305
30k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
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