command-line-interface

How to handle a ctrl-break signal in a command line interface

妖精的绣舞 提交于 2019-11-26 18:26:58
问题 Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface. Edit: I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time... I am building a command-line interface application that accepts commands from a user. I have a signal handler setup to catch the signals, which then sets a flag that I need to terminate the application. The

How to create a spinning command line cursor?

寵の児 提交于 2019-11-26 18:21:36
Is there a way to print a spinning cursor in a terminal using Python? nos Something like this, assuming your terminal handles \b import sys import time def spinning_cursor(): while True: for cursor in '|/-\\': yield cursor spinner = spinning_cursor() for _ in range(50): sys.stdout.write(next(spinner)) sys.stdout.flush() time.sleep(0.1) sys.stdout.write('\b') Victor Moyseenko Easy to use API (this will run the spinner in a separate thread): import sys import time import threading class Spinner: busy = False delay = 0.1 @staticmethod def spinning_cursor(): while 1: for cursor in '|/-\\': yield

cordova run android executes fine. But Android 4.1.2 doesn't start the app

我怕爱的太早我们不能终老 提交于 2019-11-26 18:07:01
问题 I'm starting to develop and android app using Cordova 5.0.0 (cordova -v prints 5.0.0), and testing it on a Moto Razr D1 with Android 4.1.2. Under Windows 7, btw. cordova build and manually copying the platforms/android/build/output/apk/android-degug.apk to the SD and installing works fine. cordova emulate android runs fine on emulator with android version >4.1.2 cordova run android builds successfully, says using apk platforms/android/build/output/apk/android-debugger.apk, which seems ok,

How to run commands via NodeJS child process?

不打扰是莪最后的温柔 提交于 2019-11-26 18:06:14
问题 I am trying to run commands on Windows via NodeJS child processes: var terminal = require('child_process').spawn('cmd'); terminal.stdout.on('data', function (data) { console.log('stdout: ' + data); }); terminal.stderr.on('data', function (data) { console.log('stderr: ' + data); }); terminal.on('exit', function (code) { console.log('child process exited with code ' + code); }); setTimeout(function() { terminal.stdin.write('echo %PATH%'); }, 2000); When it calls ti.stdin.write , it writes it to

How to access PHP with the Command Line on Windows?

醉酒当歌 提交于 2019-11-26 16:08:27
I am trying to learn how to access PHP scripts from the command line (CLI) Below is an image from my attempt, please help. I am running Windows 7 You need to add your PHP installation directory to the %PATH% environment variable, or work from the PHP installation directory. To add it to path (The best approach - Edited for Windows 7 ): Right-click on a My Computer icon Click Properties Click Advanced system settings from the left nav Click Advanced tab Click Environment Variables button In the System Variables section, select Path (case-insensitive) and click Edit button Add a semi-colon ( ; )

Is there an easy way to pass a “raw” string to grep?

人走茶凉 提交于 2019-11-26 16:07:52
grep can't be fed "raw" strings when used from the command-line, since some characters need to be escaped to not be treated as literals. For example: $ grep '(hello|bye)' # WON'T MATCH 'hello' $ grep '\(hello\|bye\)' # GOOD, BUT QUICKLY BECOMES UNREADABLE I was using printf to auto-escape strings: $ printf '%q' '(some|group)\n' \(some\|group\)\\n This produces a bash-escaped version of the string, and using backticks, this can easily be passed to a grep call: $ grep `printf '%q' '(a|b|c)'` However, it's clearly not meant for this: some characters in the output are not escaped, and some are

How can I beautify JavaScript code using Command Line?

别等时光非礼了梦想. 提交于 2019-11-26 15:46:54
I am writing a batch script in order to beautify JavaScript code. It needs to work on both Windows and Linux . How can I beautify JavaScript code using the command line tools? Alan Storm First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at http://jsbeautifier.org/ , because it's what I found first. Downloads its file https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js Second, download and install The Mozilla group's Java based Javascript engine, Rhino . "Install" is a little bit misleading; Download the zip file, extract everything,

Lock statement vs Monitor.Enter method

老子叫甜甜 提交于 2019-11-26 15:45:07
问题 I suppose that this is an interesting code example. We have a class -- let's call it Test -- with a Finalize method. In the Main method there are two code blocks where I am using a lock statement and a Monitor.Enter() call. Also, I have two instances of the Test class here. The experiment is pretty simple: Null the Test variable within locking block and then try to collect it manually with the GC.Collect method call. So, to see the Finalize call I am calling the GC.WaitForPendingFinalizers

How to get tf.exe (TFS command line client)?

a 夏天 提交于 2019-11-26 15:36:35
问题 What's the minimum amount of software I need to install to get the 'tf.exe' program? 回答1: You need to install Team Explorer, it's best to install the version of Team Explorer that matches the version of TFS you are using e.g. if you're using TFS 2010 then install Team Explorer 2010. 2012 version http://www.microsoft.com/en-gb/download/details.aspx?id=30656 2013 version http://www.microsoft.com/en-us/download/details.aspx?id=40776 You also might be interested in the TFS power tools. They add

Remove first N lines of a file in place in unix command line

落爺英雄遲暮 提交于 2019-11-26 15:27:17
I'm trying to remove the first 37 lines from a very, very large file. I started trying sed and awk, but they seem to require copying the data to a new file. I'm looking for a "remove lines in place" method, that unlike sed -i is not making copies of any kind, but rather is just removing lines from the existing file. Here's what I've done... awk 'NR > 37' file.xml > 'f2.xml' sed -i '1,37d' file.xml Both of these seem to do a full copy. Is there any other simple CLI that can do this quickly without a full document traversal? There's no simple way to do inplace editing using UNIX utilities, but