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
110
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
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
170
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
EventSourcingの理想と現実
wenas
6
2.2k
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
190
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
420
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
500
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
300
役立つログに取り組もう
irof
28
9.3k
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
270
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
200
Java ジェネリクス入門 2024
nagise
0
680
Quine, Polyglot, 良いコード
qnighy
4
610
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Fireside Chat
paigeccino
33
3k
Building Adaptive Systems
keathley
38
2.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Rails Girls Zürich Keynote
gr2m
93
13k
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