Popularity
0.5
Growing
Activity
0.0
Stable
8
3
1

Code Quality Rank: L5
Programming language: Swift
License: MIT License
Tags: Command Line    
Latest version: v1.0.0

Phiole alternatives and similar libraries

Based on the "Command Line" category.
Alternatively, view Phiole alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Phiole or a related project?

Add another 'Command Line' Library

README

No longer maintained!

Phiole - Φole

License Platform Language Issues Cocoapod

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

:warning: Phiole is not a login system. Use instead project like SLF4Swift

Usage

Write to ouput stream

csl.println("write string and pass to the new line")
csl.print("write string without new line")
csl.println() // write new line

Write to error stream

csl.errorln("write an error")

Read from user input

if line = csl.readLine() {
  // do something
}

Writing to a file

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()

Add some colors in terminal or xcode

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

For Xcode

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

More examples

In main.swift

Setup

Copy/Paste

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.

Licence

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.

Logo

By kodlian, inspired by apple swift logo

Why a logo?

I like to see an image for each of my projects when I browse them with SourceTree


*Note that all licence references and agreements mentioned in the Phiole README section above are relevant to that project's source code only.