command-line-interface

PHP CLI - get user input while still doing things in background

↘锁芯ラ 提交于 2019-11-28 10:17:53
问题 I'm working on a game, written in PHP and that runs in a console. Think back to old MUDs and other text-based games, even some ASCII art! Anyway, what I'm trying to do is have things happening while also accepting user input. For instance, let's say it's a two player game and Player 1 is waiting for Player 2 to make a move. This is easily done by just listening for a message. But what if Player 1 wants to change some options? What if they want to view details on aspects of the game state?

Common Language Runtime detected an invalid program?

本秂侑毒 提交于 2019-11-28 09:00:13
问题 I have this error repeating continuously in my program. I have tried the following: Restart Visual Studio Clean and Rebuild Solution When I step through the code line by line, it stops leaving me totally confused at a method call: GenerateWorksheetPart1Content(WorksheetPart worksheetPart1) I don't understand why it stops there. The parameter is not null at the point. What could be causing the error? 回答1: MSDN - InvalidProgramException Excerpt: The exception that is thrown when a program

Why doesn't xmlstarlet select all nodes?

痴心易碎 提交于 2019-11-28 08:55:43
问题 Consider this example from w3schools: <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per

argparse optional subparser (for --version)

穿精又带淫゛_ 提交于 2019-11-28 07:32:08
I have the following code (using Python 2.7): # shared command line options, like --version or --verbose parser_shared = argparse.ArgumentParser(add_help=False) parser_shared.add_argument('--version', action='store_true') # the main parser, inherits from `parser_shared` parser = argparse.ArgumentParser(description='main', parents=[parser_shared]) # several subcommands, which can't inherit from the main parser, since # it would expect subcommands ad infinitum subparsers = parser.add_subparsers('db', parents=[parser_shared]) ... args = parser.parse_args() Now I would like to be able to call this

How to display output of `git branch` on-screen in same CLI terminal? [duplicate]

霸气de小男生 提交于 2019-11-28 07:06:39
问题 This question already has an answer here: Git branch command behaves like 'less' 8 answers My apologies, but I am having trouble phrasing my question. I'm running on CLI ( zsh if it matters), using git version 2.20.0 and on macOS (think I've encountered it on my Ubuntu system at home too). Question: How do you display the output of git branch on the same CLI screen? i.e. if I run, $ git branch $ it pops open a new screen/window (inside my CLI) showing me all my branches. Pressing q closes the

aws eb cli 3 sets up application for wrong account

坚强是说给别人听的谎言 提交于 2019-11-28 05:56:44
I have multiple AWS accounts and I'm trying out the new command line interface for elastic beanstalk EB CLI 3. When I run the following command eb init I get prompted for the region (good) and then it asks me to "Select an application to use" where it lists the applications from another AWS account (for staging). If I go ahead and "Create new application" that application will be created in my staging account. Is there some way to configure eb cli3 and get it to use different access keys? You can set up a new profile to use with the EB CLI. Profiles are shared between the AWS CLI and the EB

embed DLL in MFC C++ EXE?

纵然是瞬间 提交于 2019-11-28 05:16:50
问题 Is it possible to embed an external CLI/C++ DLL into a MFC EXE as a embedded resource or something like that? My application currently connects to DLL sitting right beside it that has some basic functions like connect to database, pull information from DB, etc.. I use LoadLibrary to use the DLL functions. Then I secure my EXE with themida and pack the EXE and DLL together. The problem is though to pack the DLL and EXE I have to disable file patching in themida which is a very strong feature.

PHP, pass parameters from command line to a PHP script

半腔热情 提交于 2019-11-28 04:32:36
I want to pass parameters from PHP Command Line Interface, and then read in the values using PHP script, something like this: <?php $name1 = $argv[1]; echo $name1; ?> I pass the variable from CLI like this: C:\xampp\php\php.exe name.php Robby The above works, I get Robby as the output. But I want to do something like this: C:\xampp\php\php.exe name.php -inputFirstName="Robby" So that the user is well informed to enter the correct parameters in the correct places. What is the appropriate way to parse these parameters? vascowhite When calling a PHP script from the command line you can use $argc

How to differentiate between http and cli requests?

六月ゝ 毕业季﹏ 提交于 2019-11-28 03:10:08
问题 The title is quiet straightforward. I have to know on server side if the script called through HTTP request or by command line. I could examine the $_SERVER['argv'] or $_SERVER['argc'] . What is the pragmatic way to do that? 回答1: http://us3.php.net/manual/en/function.php-sapi-name.php <?php echo PHP_SAPI; echo php_sapi_name(); ?> 回答2: Look at the keys in $_SERVER. If it is a cli request, you shouldn't see any that start with "HTTP". Here is some simple test code: <?php foreach( $_SERVER as $k

Python DistributionNotFound Error after installing EB CLI 3.0

谁都会走 提交于 2019-11-28 03:09:27
问题 Have tried many things, but keep getting this error after multiple attempts to update python, pip, etc. I am on OS X running 10.9.5. CMD% eb Traceback (most recent call last): File "/usr/local/bin/eb", line 5, in <module> from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666,