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

Useful Command Line Tools in Swift 3

giginet
October 26, 2016

Useful Command Line Tools in Swift 3

potatotips #34

giginet

October 26, 2016
Tweet

More Decks by giginet

Other Decks in Programming

Transcript

  1. $ toybox create Snippet $ toybox create $ toybox create

    —-platform macos $ toybox open Snippet $ toybox list https://github.com/giginet/Toybox
  2. Carthage/Commandant struct ListOptions: OptionsProtocol { typealias ClientError = ToyboxError let

    platform: Platform? static func create(_ platform: Platform?) -> ListOptions { return self.init(platform: platform) } static func evaluate(_ m: CommandMode) -> Result<ListOptions, CommandantError<ToyboxError>> { return create <*> m <| Option<Platform?>(key: "platform", defaultValue: nil, usage: "Platform to list (ios/mac/tvos)") } } struct ListCommand: CommandProtocol { typealias Options = ListOptions typealias ClientError = ToyboxError let verb = "list" let function = "List the Playground" func run(_ options: Options) -> Result<(), ToyboxError> { // Do Something return .success() } }
  3. class Toybox < Formula desc "Xcode Playground management made easy"

    homepage "https://github.com/giginet/Toybox" url "https://github.com/giginet/Toybox.git", :tag => "0.1.0", :revision => "e65059061cd33bdbc01fe9883e6e4d2c863979f4", :shallow => false head "https://github.com/giginet/Toybox.git", :shallow => false depends_on :xcode => ["8.0", :build] depends_on 'carthage' => :build def install system "make", "prefix_install", "PREFIX=#{prefix}" bash_completion.install "Sources/Scripts/toybox-bash- completion" => "toybox" zsh_completion.install "Sources/Scripts/toybox-zsh-completion" => "_toybox" end test do system bin/"toybox" end end