No longer maintained!
Simple object to wrap three NSFileHandle: 'output', 'error' to write and 'input' to read
There is of course a default instance for standard streams
let csl = Phiole.std
This object could be used in script or CLI application instead of using println()
.
This adds the following abilities :
- Write to a file by declaring transparently an NSFileHandle as output stream
- Write to error stream
- Read from input stream
Swift scripts: How to write small command line scripts in Swift
csl.println("write string and pass to the new line")
csl.print("write string without new line")
csl.println() // write new line
csl.errorln("write an error")
if line = csl.readLine() {
// do something
}
Create the file handle for writing (file must exist)
if let fileHandle = NSFileHandle(forWritingAtPath: "myoutput.file") { ..
Initialize the console object
var newCsl = csl.withOutput(fileHandle)
// or with more code
var newCsl = Phiole(input: input: Phiols.std.input,
output: fileHandle, error: Phiols.std.error)
Write as usual
newCsl.println("write to a file")
...
Finally don't forget to close the file handle at the end
fileHandle.closeFile()
You can manually add color with decorated method ( see
PhioleColor.swift
)
csl.println(Phiole.Color.green.fg("write in red"))
Or for all ouputs
csl.outputColor = .Green
csl.errorColor = .Red
... write here ...
// reset
csl.outputColor = .None
csl.errorColor = .None
// or deactivate
csl.colorize = false
Color shortcuts could be added as you can see in Phiole+Shortcut
XcodeColors is a simple plugin for Xcode, it allows you to use colors in the Xcode debugging console.
Full installation instructions can be found on the XcodeColors project page:
https://github.com/robbiehanson/XcodeColors
Then you must add environment variable XcodeColors
= YES
in your Scheme
In main.swift
Just copy/paste code with licence in your script, or import swift files or project in your CLI project
Using cocoapods
Add pod 'Phiole', :git => 'https://github.com/phimage/Phiole.git'
to your Podfile
and run pod install
.
Add use_frameworks!
to the end of the Podfile
.
The MIT License (MIT)
Copyright (c) 2015 Eric Marchand (phimage)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
By [kodlian] (http://www.kodlian.com/), inspired by apple swift logo
I like to see an image for each of my projects when I browse them with SourceTree