command-line-interface

Color ouput with Swift command line tool

牧云@^-^@ 提交于 2019-12-02 20:45:55
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! cyt Swift has built in unicode support. This invalidates using of back slash. So that I use color codes with "\u{}" syntax.

PHP APC in CLI mode

谁说胖子不能爱 提交于 2019-12-02 20:35:49
Does APC module in PHP when running in CLI mode support code optimization? For example, when I run a file with php -f <file> will the file be optimized with APC before executing or not? Presuming APC is set to load in config file. Also, will the scripts included with require_once be also optimized? I know optimization works fine when running in fastcgi mode, but I'm wondering if it also works in CLI. apc_* functions work, but I'm wondering about the code optimization, which is the main thing I'm after here. Happy day, Matic The documentation of apc.enable_cli , which control whether APC should

Search for files & file names using silver searcher

我怕爱的太早我们不能终老 提交于 2019-12-02 20:28:19
Using Silver Searcher, how can I search for: (non-binary) files with a word or pattern AND all filenames , with a word or pattern including filenames of binary files. Other preferences: would like to have case insensitive search and search through dotfiles. Tried to alias using this without much luck: alias search="ag -g $1 --smart-case --hidden && ag --smart-case --hidden $1" vincentleest According to the man page of ag -G --file-search-regex PATTERN Only search files whose names match PATTERN. You can use the -G option to perform searches on files matching a pattern. So, to answer your

How to read from stdin or from a file if no data is piped in Python?

若如初见. 提交于 2019-12-02 19:15:39
I have a CLI script and want it to read data from a file. It should be able to read it in two ways : cat data.txt | ./my_script.py ./my_script.py data.txt —a bit like grep , for example. What I know: sys.argv and optparse let me read any args and options easily. sys.stdin let me read data piped in fileinput make the full process automatic Unfortunately: using fileinput uses stdin and any args as input. So I can't use options that are not filenames as it tries to open them. sys.stdin.readlines() works fine, but if I don't pipe any data, it hangs until I enter Ctrl + D I don't know how to

“Fatal error: Call to undefined method PHPUnit_Util_Filter::addfiletofilter() in /usr/bin/phpunit on line 48”

杀马特。学长 韩版系。学妹 提交于 2019-12-02 19:09:55
问题 I have just installed phpunit using PEAR on our Ubuntu/Linux server ( Linux mccoy 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64 GNU/Linux ) when I try to run a unit test I get the error: "Fatal error: Call to undefined method PHPUnit_Util_Filter::addfiletofilter() in /usr/bin/phpunit on line 48" I have googled this and came across a few threads on it however none of these seem to fix my issue. I have added the following line to my /etc/php5/cli/php.ini: include_path = ".

Is there a definitive *nix command line tool for inspecting protocol buffers? [closed]

若如初见. 提交于 2019-12-02 19:02:15
I'm looking for a command-line utility that will, at a minimum, render binary protobuf data in human-readable form. Filtering and selection options (along the lines of cut for text) would be nice, but the primary object is to make the data visible for debugging purposes. If there is no definitive tool for the job, links to relevant packages are fine. The Protocol Compiler -- protoc -- has this functionality built-in via the --decode and --decode_raw flags. This is the same tool you use to generate code from a .proto file so is likely already installed. For example: protoc --decode_raw <

Trying to Install AWS CLI, stuck on a step

南楼画角 提交于 2019-12-02 18:58:56
Im trying to install aws for the mac command line, I guess I dont understand what I need to do I installed the aws bundle with wget on the terminal, unziped it did everything, but when I need to configure my credentials nothing comes up when I put aws configure.. Here are the Instructions: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html Here is what is ouputed an$ aws configuration Traceback (most recent call last): File "/usr/local/bin/aws", line 15, in <module> import awscli.clidriver File "/usr/local/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 31,

Change working directory in my current shell context when running Node script

牧云@^-^@ 提交于 2019-12-02 18:18:00
I am trying to change the working directory of my Node.js script when it is run from a bin script. I have something like the following: #!/usr/bin/env node process.chdir('/Users') When I then run this file with ./bin/nodefile , it exits, but the working directory of the current shell context has not changed. I have also tried shelljs , but that does not work either. What is the best way to do this? I understand it's working but it's just in a separate process. The correct way to change directories is actually with process.chdir(directory) . Here's an example from the documentation : console

Using jq, convert array of name/value pairs to object with named keys

怎甘沉沦 提交于 2019-12-02 18:08:10
问题 Given a json file in the format as : [ { "name" : "A", "value" : "4" }, { "name" : "B", "value" : "2" }, { "name" : "C", "value" : { "X": "Something", "Y": "Else" } } ] How would I convert it to something like this using jq: { "A": "4", "B": "2", "C": { "X": "Something", "Y": "Else" } } I did come close using jq 'map( { (.name): .value } ) but that still leaves each object in its separate braces instead of having them all together. 回答1: Using your approach, simply add add to your filter: map(

De-activate a maven profile from command line

巧了我就是萌 提交于 2019-12-02 17:49:39
I have a profile activated by default in my maven setting file ~/.m2/settings.xml . Is it possible to deactivate it from the command line by doing something like this: mvn -P!profileActivatedByDefault Yes indeed, you have the right way. From maven profiles user guide Deactivating a profile Starting with Maven 2.0.10, one or more profiles can be deactivated using the command line by prefixing their identifier with either the character '!' or '-' as shown below: mvn groupId:artifactId:goal -P !profile-1,!profile-2 This can be used to deactivate profiles marked as activeByDefault or profiles that