command-line-interface

How to check with PHP if the script is being run from the console or browser request?

一曲冷凌霜 提交于 2020-02-17 06:58:07
问题 I tried things like $_ENV['CLIENTNAME'] == 'Console' but that seems to work on only certain OS's (worked in windows, not linux). I tried !empty($_ENV['SHELL']) but that doesn't work always either... Is there a way to check this that will work in all OS's/environments? 回答1: Use php_sapi_name() Returns a lowercase string that describes the type of interface (the Server API, SAPI) that PHP is using. For example, in CLI PHP this string will be "cli" whereas with Apache it may have several

Override undocumented help area in Python's cmd module

烈酒焚心 提交于 2020-02-03 09:20:48
问题 I am using Python's cmd module to build a little CLI tool. I am not a fan of showing the undocumented commands listed. So when I type 'help' I would like to just show the documented commands. Currently typing help shows this: Documented commands (type help <topic>): ======================================== exit help projects Undocumented commands: ====================== EOF I have that EOF bit in there because I need to exit gracefully, as is documented by the cmd examples. But I don't want

Override undocumented help area in Python's cmd module

我只是一个虾纸丫 提交于 2020-02-03 09:20:06
问题 I am using Python's cmd module to build a little CLI tool. I am not a fan of showing the undocumented commands listed. So when I type 'help' I would like to just show the documented commands. Currently typing help shows this: Documented commands (type help <topic>): ======================================== exit help projects Undocumented commands: ====================== EOF I have that EOF bit in there because I need to exit gracefully, as is documented by the cmd examples. But I don't want

swift - how to print to console multi line Strings in 2 distinct columns on the screen

梦想与她 提交于 2020-01-30 13:25:27
问题 I have 2 very long strings which span multiple lines each and want to print to console both strings in their own "column" to the terminal i.e. let veryLongStringWithNewLines = "a very long string with \n and blah blah \n and more text ....." let anotherVeryLongStringWithNewLines = "......." print ("\(veryLongStringWithNewLines) %???Break Screen in Center???% \(anotherVeryLongStringWithNewLines)") // <<<< TO THE CONSOLE I want to divide the console into 2 columns such that each string is

Cannot find Typescript module even though tsc successfully manages to resolve it

自作多情 提交于 2020-01-29 09:11:27
问题 I have a Node.js project written in Typescript which is expected to run as a CLI, and am having trouble to import a module located out of the node_modules directory using an absolute path (relative paths work fine). It might be important to mention that I am using the oclif framework for building my CLI. My project is organized as follows: cli |--node_modules |--src |--my-module.ts |--subdir |--index.ts Within my-module.ts I have: export class MyClass { myClassFcn(s: string) { return 'result'

how to print a custom message between two @click.option()?

只谈情不闲聊 提交于 2020-01-25 07:59:17
问题 I'm writing a command-line tool using Python Click package. I want to print a custom message between two @click.option() . Here is the sample code for what I want to achieve: import click @click.command() @click.option('--first', prompt='enter first input') print('custom message') # want to print custom message here @click.option('--second', prompt='enter second input') def add_user(first, second): print(first) print(second) add_user() Any help how can I do this? Thanks in advance. 回答1: You

MySQL 8 Select Statement to get 'Last_query_cost'

夙愿已清 提交于 2020-01-25 04:04:04
问题 There is a MySQL CLI command SHOW STATUS LIKE 'Last_query_cost'; but how to get that info with plain SELECT Query? Is there any kind of escaping/wrapping MySQL CLI command so it can be used in plain SELECT statement? Perhaps there is a schema that I could query with SELECT in order to obtain the info provided by SHOW STATUS LIKE 'Last_query_cost'; command? 回答1: In mysql v5.7 and earlier, all global and session variables are stored in the INFORMATION_SCHEMA GLOBAL_STATUS and SESSION_STATUS

Getting “/usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directo” when running S3 command on Mac

旧街凉风 提交于 2020-01-24 23:06:19
问题 I'm using Mac High Sierra. I'm tryhign to install Amazon's S3 cli tools. I thought I had installed successfully through pip, but then I got this error tryihng to run an s3 command ... localhost:~ davea$ s3cmd --recursive ls s3://sbdasset.springboardonline.com | grep "resource" -bash: /usr/local/bin/s3cmd: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory Per the answer here -- pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or

How to use Terminal API to listen to all terminal output in vscode?

只谈情不闲聊 提交于 2020-01-24 09:37:06
问题 I want to listen to terminal output from extension, such as tsc -w and catch the moment if the output contains similar text: Found 1 error. Watching for file changes. Or the error exit code or something like that. Is it possible to do with old API or Proposed API? Tried: terminal.onDidWriteData(data => { console.log('onDidWriteData: ', data.trim()); }); It just outputs autogenerated rubbish like: Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. 回答1: Looks like it

Move printing position of Command Line Interface in Java without using External library

╄→尐↘猪︶ㄣ 提交于 2020-01-23 12:33:39
问题 In C, I recalled that I can move the invisible caret around the command line interface screen with respect to the line and character position, meaning I can make the program print any text anywhere on the screen. Do we have such command in Java? For instance, here is a pseudocode in C: int main(){ printf("launching program\n"); moveTo(4,3); //move to line 4 at character index 3 on the screen. printf("AAA"); moveTo(3,0); //move to line 3 at character index 0 on the screen. printf("BBB");