{"id":17090845,"url":"https://github.com/phimage/phiole","last_synced_at":"2025-04-12T22:29:31.153Z","repository":{"id":30954747,"uuid":"34512860","full_name":"phimage/Phiole","owner":"phimage","description":"Allow to write or read from standards stream or files for script or CLI application","archived":false,"fork":false,"pushed_at":"2018-09-10T14:36:03.000Z","size":477,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T03:38:38.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phimage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-24T10:36:40.000Z","updated_at":"2018-09-10T14:36:05.000Z","dependencies_parsed_at":"2022-09-09T03:21:05.095Z","dependency_job_id":null,"html_url":"https://github.com/phimage/Phiole","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FPhiole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FPhiole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FPhiole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FPhiole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phimage","download_url":"https://codeload.github.com/phimage/Phiole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248639463,"owners_count":21137846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T13:56:53.332Z","updated_at":"2025-04-12T22:29:31.128Z","avatar_url":"https://github.com/phimage.png","language":"Swift","readme":"**No longer maintained!**\n\n# Phiole - Φole\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n            )](http://mit-license.org) [![Platform](http://img.shields.io/badge/platform-iOS/MacOS-lightgrey.svg?style=flat\n             )](https://developer.apple.com/resources/) [![Language](http://img.shields.io/badge/language-swift-orange.svg?style=flat\n             )](https://developer.apple.com/swift) [![Issues](https://img.shields.io/github/issues/phimage/Phiole.svg?style=flat\n           )](https://github.com/phimage/Phiole/issues)  [![Cocoapod](http://img.shields.io/cocoapods/v/Phiole.svg?style=flat)](http://cocoadocs.org/docsets/Phiole/)\n\n[\u003cimg align=\"left\" src=\"logo-128x128.png\" hspace=\"20\"\u003e](#logo)\n\nSimple object to wrap three [NSFileHandle](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileHandle_Class/index.html): 'output', 'error' to write and 'input' to read\n\nThere is of course a default instance for [standard streams](http://en.wikipedia.org/wiki/Standard_streams)\n```swift\nlet csl = Phiole.std\n```\n\nThis object could be used in script or CLI application instead of using `println()`.\nThis adds the following abilities :\n* Write to a file by declaring transparently an [NSFileHandle](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileHandle_Class/index.html) as output stream\n* Write to error stream\n* Read from input stream\n\n[Swift scripts: How to write small command line scripts in Swift](http://practicalswift.com/2014/06/07/swift-scripts-how-to-write-small-command-line-scripts-in-swift/)\n\n:warning: Phiole is not a login system. Use instead project like [SLF4Swift](https://github.com/phimage/SLF4Swift)\n\n# Usage\n## Write to ouput stream\n```swift\ncsl.println(\"write string and pass to the new line\")\ncsl.print(\"write string without new line\")\ncsl.println() // write new line\n```\n## Write to error stream\n```swift\ncsl.errorln(\"write an error\")\n```\n## Read from user input\n```swift\nif line = csl.readLine() {\n  // do something\n}\n```\n## Writing to a file\nCreate the file handle for writing (file must exist)\n```swift\nif let fileHandle = NSFileHandle(forWritingAtPath: \"myoutput.file\") { ..\n```\nInitialize the console object\n```swift\nvar newCsl = csl.withOutput(fileHandle)\n// or with more code\nvar newCsl = Phiole(input: input: Phiols.std.input,\n                    output: fileHandle, error: Phiols.std.error)\n```\nWrite as usual\n```swift\nnewCsl.println(\"write to a file\")\n...\n```\nFinally don't forget to close the file handle at the end\n```swift\nfileHandle.closeFile()\n```\n\n## Add some colors in terminal or xcode\n\nYou can manually add color with decorated method ( see\n[`PhioleColor.swift`](/PhioleColor.swift))\n```\ncsl.println(Phiole.Color.green.fg(\"write in red\"))\n```\nOr for all ouputs\n```\ncsl.outputColor = .Green\ncsl.errorColor = .Red\n... write here ...\n\n// reset\ncsl.outputColor = .None\ncsl.errorColor = .None\n// or deactivate\ncsl.colorize = false\n```\nColor shortcuts could be added as you can see in [Phiole+Shortcut](/Phiole+ColorShortcut.swift)\n\n### For Xcode\n**XcodeColors** is a simple plugin for Xcode, it allows you to use colors in the Xcode debugging console.\n\nFull installation instructions can be found on the XcodeColors project page:  \nhttps://github.com/robbiehanson/XcodeColors\n\nThen you must add environment variable `XcodeColors` = `YES` in your Scheme\n\n## More examples\nIn [main.swift](/Phiole/main.swift)\n\n# Setup #\n\n## Copy/Paste ##\nJust copy/paste code with licence in your script, or import swift files or project in your CLI project\n\n## Using [cocoapods](http://cocoapods.org/) ##\n\nAdd `pod 'Phiole', :git =\u003e 'https://github.com/phimage/Phiole.git'` to your `Podfile` and run `pod install`.\n\nAdd `use_frameworks!` to the end of the `Podfile`.\n\n##  Licence\n```\nThe MIT License (MIT)\n\nCopyright (c) 2015 Eric Marchand (phimage)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n# Logo #\nBy [kodlian] (http://www.kodlian.com/), inspired by [apple swift logo](http://en.wikipedia.org/wiki/File:Apple_Swift_Logo.png)\n### Why a logo?\nI like to see an image for each of my projects when I browse them with [SourceTree](http://www.sourcetreeapp.com/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphimage%2Fphiole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphimage%2Fphiole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphimage%2Fphiole/lists"}