command-line-interface

Use python click command with a class with variadic arguments

房东的猫 提交于 2019-12-13 01:28:10
问题 I have a class that gets initialized with a previously unknown number of arguments and I want it to be done on cli using python click package. My issue is that I can't manage to initialize it and run a click command: $ python mycode.py arg1 arg2 ... argN click_command because with variadic arguments option nargs=-1 click don't recognize the click_command as a command. How can I input N args and then run a command using click? Setting a defined number of arguments, like nargs=5 , solves the

python 3 argparse call a function

南楼画角 提交于 2019-12-13 01:25:27
问题 I wanted to create a commandline-like / shell-like interface in python3. Argparse seems to do the job of parsing and displaying the help/error messages. According to the python3 documentation of argparse, there is a func= argument that can be used to get your function called by argparse . # sub-command functions def foo(args): print(args.x * args.y) def bar(args): print('((%s))' % args.z) # create the top-level parser parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() #

python click app is failing with indication of “missing argument” but cannot locate the issue

流过昼夜 提交于 2019-12-13 00:32:06
问题 I am creating an app with Click in python 3.6. I seem to have an error that I cannot find. I have posted my code below. The problem is that when I type: python clickapp.py --help all is good. But when I type python clickapp.py simplerequest --help I get an error indicating that I am missing the argument "directory", but there is no traceback to indicate the source of the error. The exact output is: Usage: clickapp.py [OPTIONS] STARTDATE ENDDATE DIRECTORY COMMAND [ARGS]... Error: Missing

non-print output in tty in python?

安稳与你 提交于 2019-12-12 19:50:28
问题 I dont know how to properly term what i want. I want to make a program that doesnt just print and scroll but still be a linux-CLI program. Lets say i write a program that does 3 things: 1, its tails a logfile 2, it shows the time 3, it runs a continous ping. And say i want the time to be displayed in lower right corner, i want the logtail to scroll in the upper 5 lines of the terminal, and i want the ping to scroll (separately) in the main body of the terminal. So what i am asking, basicly,

Managed c++/cli .net convert fixed Byte array to a String^

孤人 提交于 2019-12-12 18:47:15
问题 How do I convert a fixed byte array to a String in managed c++/cli ? For example I have the following Byte array. Byte byte_data[5]; byte_data[0]='a'; byte_data[1]='b'; byte_data[2]='c'; byte_data[3]='d'; byte_data[4]='e'; I have tried the following code String ^mytext=System::Text::UTF8Encoding::UTF8->GetString(byte_data); I get the following error: error C2664: 'System::String ^System::Text::Encoding::GetString(cli::array<Type,dimension> ^)' : cannot convert parameter 1 from 'unsigned char

PHP extension loaded in command line (cli) but not loaded by apache

只愿长相守 提交于 2019-12-12 16:14:03
问题 Final Update. Problem Solved. The way I solve the problem is re-install Apache and PHP entirely from source following the instruction by the following link. http://dan.drydog.com/apache2php.html Then do the extension by build the extension directly into PHP following the instruction by the link down below. The only thing is that the binaries are all only in the specific path, which I think is a easy problem to solve though. Thanks everyone, this is my first post in Stackoverflow and I spend

Joining Columns on Command Line with Paste or PR Not Working

[亡魂溺海] 提交于 2019-12-12 15:49:50
问题 So I have two files that I want to take columns out of and join them in a single file. f1: 02/10/2013,16:00:00.091,123.82,OTCX,GLO,,123.82 02/10/2013,16:00:03.072,123.766,FXN,NAM,,123.766 02/10/2013,16:00:03.491,123.769,FXN,,,123.769 02/10/2013,16:00:03.565,123.79,COMM,ASI,HKG,123.79 02/10/2013,16:00:03.721,123.769,FXN,NAM,NYC,123.769 02/10/2013,16:00:04.194,123.81,AKM,EUR,MOW,123.81 02/10/2013,16:00:06.130,123.764,FXN,NAM,NYC,123.764 02/10/2013,16:00:06.330,123.764,FXN,,,123.764 02/10/2013

automate a windows command line utility with a batch file - send keystrokes to std input after utility starts

廉价感情. 提交于 2019-12-12 15:43:34
问题 I have a command line utility which opens a serial connection specified by args sent in (duh) the command line. After the utility starts, I can type into the std input to send strings to the port to which I am connected. What I would like to do is start the utility with a batch file (easy enough), then automate the keystrokes I wish to send. I am having no luck on my own and need some expert advice. I'll give a more specific example: I start teraterm.exe (opensource serial communication

asterisk agi (php) file debugging

被刻印的时光 ゝ 提交于 2019-12-12 12:52:33
问题 does anyone know the steps required to debug the agi secript (a2billing.php) of asterisk . I am able to remote debug php cli if i call it form the linux console. but if it runs from within asterisk , it does not work. any idea how to debug it ? 回答1: To turn debug mode of a2billing you have to go config, and in agi-confX put verbose ->DEBUG(see comments) After that you can check a2billign debug file(specified in /etc/a2billng.conf) or do from console asterisk -r agi set debug on core set

CLI/C++: void* to System::Object

我只是一个虾纸丫 提交于 2019-12-12 12:09:45
问题 This is a similar question to this SO post, which I have been unable to use to solve my problem. I have included some code here, which will hopefully help someone to bring home the message that the other posting was getting at. I want to write a CLI/C++ method that can take a void pointer as a parameter and return the managed object (whose type I know) that it points to. I have a managed struct: public ref struct ManagedStruct { double a; double b;}; The method I am trying to write, which