Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building CLI with Swift

Building CLI with Swift

Oleksandr Voronov

March 19, 2016
Tweet

More Decks by Oleksandr Voronov

Other Decks in Programming

Transcript

  1. IT Saturday • @aleks_voronov • Stanfy GNU STANDARD LONG FLAGS

    $ ls --all $ ruby --version $ git commit --message "..."
  2. IT Saturday • @aleks_voronov • Stanfy COMBINED FLAGS $ git

    commit -a -m "..." $ git commit -am "..."
  3. IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1

    - STDOUT 2 - STDERR $ cat nofile > cat: nofile: No such file or directory
  4. IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1

    - STDOUT 2 - STDERR $ cat nofile 2>>err.log
  5. IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1

    - STDOUT 2 - STDERR $ cat nofile 2>&1
  6. IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1

    - STDOUT 2 - STDERR $ cat nofile 2>>err.log 1>>out.log
  7. IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1

    - STDOUT 2 - STDERR $ cat nofile 2>/dev/null
  8. IT Saturday • @aleks_voronov • Stanfy 0 - STDIN 1

    - STDOUT 2 - STDERR $ cat nofile 2>&1 | grep kernel
  9. IT Saturday • @aleks_voronov • Stanfy SWIFT COMPILE ⚙ $

    swiftc script.swift -o myscript $ ./myscript
  10. IT Saturday • @aleks_voronov • Stanfy $ find . -iname

    '*.swift' | xargs swiftc -o script EXECUTING MULTIPLE FILES
  11. IT Saturday • @aleks_voronov • Stanfy SYSTEM DEPENDENCIES $ swiftc

    script.swift $ xcrun -sdk macosx swiftc script.swift
  12. IT Saturday • @aleks_voronov • Stanfy CUSTOM DEPENDENCIES -F $

    swift -F /Carthage/Build/Mac script.swift
  13. IT Saturday • @aleks_voronov • Stanfy $ xcrun \ -sdk

    macosx swiftc \ -F Carthage/Build/Mac script.swift COMPILING DEPENDENT SCRIPT > dyld: Library not loaded: @rpath
  14. 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
  15. 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