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
ヤプリ新卒SREの オンボーディング
masaki12
0
130
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
3
350
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
3
270
Outline View in SwiftUI
1024jp
1
340
RubyLSPのマルチバイト文字対応
notfounds
0
120
Jakarta EE meets AI
ivargrimstad
0
170
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.3k
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
5
1.5k
Quine, Polyglot, 良いコード
qnighy
4
650
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Six Lessons from altMBA
skipperchong
27
3.5k
Teambox: Starting and Learning
jrom
133
8.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Adopting Sorbet at Scale
ufuk
73
9.1k
KATA
mclloyd
29
14k
Navigating Team Friction
lara
183
14k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
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