command-line-interface

Color ouput with Swift command line tool

淺唱寂寞╮ 提交于 2019-12-31 10:36:33
问题 I'm writing a command line tool with Swift and I'm having trouble displaying colors in my shell. I'm using the following code: println("\033[31;32mhey\033[39;39m") or even NSFileHandle.fileHandleWithStandardOutput().writeData("\033[31;32mhey\033[39;39m".dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion: true)!) It works when I use a simple echo in php (the text is displayed in green) but is there a reason it doesn't work in a Swift command line tool? Thanks! 回答1: Swift has built

Color ouput with Swift command line tool

好久不见. 提交于 2019-12-31 10:36:04
问题 I'm writing a command line tool with Swift and I'm having trouble displaying colors in my shell. I'm using the following code: println("\033[31;32mhey\033[39;39m") or even NSFileHandle.fileHandleWithStandardOutput().writeData("\033[31;32mhey\033[39;39m".dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion: true)!) It works when I use a simple echo in php (the text is displayed in green) but is there a reason it doesn't work in a Swift command line tool? Thanks! 回答1: Swift has built

use angular 2 instead of angular 4 with angular-cli

﹥>﹥吖頭↗ 提交于 2019-12-31 05:00:26
问题 How can i create angular 2 app with angular-cli instead of angular 4? https://github.com/angular/angular-cli my package.json: "dependencies": { "@angular/animations": "^4.0.0", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "core-js": "^2.4.1", "rxjs": "^5.1.0", "zone.js": "^0.8.4" },

Which method to detect run mode of php script is more reliable?

雨燕双飞 提交于 2019-12-31 04:27:08
问题 I now to ways to detect weather php script runs in cli or web server mode: if (defined('STDIN')) or: if (isset($argc)) Do they equally reliable or one of them is more ? 回答1: Neither. Check the value returned from php_sapi_name() . 回答2: $_SERVER['REQUEST_METHOD'] won't be set, due to the lack of a HTTP request. I think defined( 'STDIN' ) or isset( $argc ) are reliable too, though. If it was up to me, I'd probably go with the defined( 'STDIN' ), as I can imagine someone accidentally setting a

How to catch error when setting launchpath in NSTask

那年仲夏 提交于 2019-12-30 18:01:11
问题 I am trying to run a commandline tool using swift 2 on a mac (10.10): let task = NSTask() task.launchPath = "/path/to/wrong/binary" task.launch() // NSPipe() stuff to catch output task.waitUntilExit() // never reached if (task.terminationStatus != 0){ NSLog("uh oh") } Since the path is wrong, my program dies with launch path not accessible . However, I don't know, how to catch this error. Using do { try } catch {} around task.launch() does not work, because it does not throw an exception,

Executing a Route (Controller/Action) using PHP CLI and Detecting a CLI Request

陌路散爱 提交于 2019-12-30 10:16:09
问题 Is there a way in Laravel 4 to run my controller/action using PHP-CLI? I have a controller/action that I would like to extend to perform an alternative action if the request comes from the CLI, so is there a way to identify the request as a CLI request? The Laravel documentation on this site seems to suggest that there is a method Request::cli() for determining if the current request is via the Artisan CLI but when I used the method in Laravel 4, it throws an error: Call to undefined method

Constantly losing storage after Cordova 6.0.0 update

早过忘川 提交于 2019-12-30 10:15:46
问题 I've been using Cordova cli for a couple years now. Today I updated from Cordova 5.4.0 to 6.0.0 npm install -g cordova@latest then I updated android platform to 5.1.0 from the previous version cordova platform update android ran it cordova run android Noticed the icon on my device was replaced and added to the end of all apps. More importantly the localstorage data is missing. Not just once but each time I run it. Long ago I ran into this issue when I rebuilt from scratch with a different

Is it mandatory to configure PHP in order to scan configuration INI files on a per-directory basis(i.e. .htaccess files in my case) by PHP?

血红的双手。 提交于 2019-12-30 07:49:31
问题 I'm using Windows 10 Home Single Language 64-bit Operating System on my machine. I've installed the latest copy of XAMPP server on my machine which ships with PHP 7.2.7 I read following pages from the PHP Manual : Scan directories .user.ini files After reading the text from these two pages one doubt came to my mind : To scan the configuration INI files on a per-directory basis( in my case '.htaccess files' ) by PHP is it mandatory to run PHP on CLI with the --with-config-file-scan-dir option

Is it mandatory to configure PHP in order to scan configuration INI files on a per-directory basis(i.e. .htaccess files in my case) by PHP?

房东的猫 提交于 2019-12-30 07:49:18
问题 I'm using Windows 10 Home Single Language 64-bit Operating System on my machine. I've installed the latest copy of XAMPP server on my machine which ships with PHP 7.2.7 I read following pages from the PHP Manual : Scan directories .user.ini files After reading the text from these two pages one doubt came to my mind : To scan the configuration INI files on a per-directory basis( in my case '.htaccess files' ) by PHP is it mandatory to run PHP on CLI with the --with-config-file-scan-dir option

How to set icon on file or directory using CLI on OS X?

守給你的承諾、 提交于 2019-12-30 06:48:08
问题 To set an icon on a file or directory is straight forward using the "Get Info" dialog in Finder. copy image from e.g. Preview open "Get Info" on file or directory press TAB to select the icon paste Cmd-V But how do you do this using the command line? 回答1: Here is a bash script "setIcon.sh" for it #!/bin/sh # Sets an icon on file or directory # Usage setIcon.sh iconimage.jpg /path/to/[file|folder] iconSource=$1 iconDestination=$2 icon=/tmp/`basename $iconSource` rsrc=/tmp/icon.rsrc # Create