Home:ALL Converter>Replicating unix kill syntax with python ArgumentParser

Replicating unix kill syntax with python ArgumentParser

Ask Time:2014-06-27T01:37:55         Author:dquigley

Json Formatter

I am working on a command shell with the python cmd class and I'm trying to mimic the behavior of the unix kill command. I want to be able to type kill -<signum> <pid> and have argument parser take the -<signum> and store it away. I can't seem to figure out how to do this with ArgumentParser since it seems to want to have all of the flags specified ahead of time and that doesn't seem reasonable with the number of signals there are.

Does anyone have any experience with this and if so how do I go about doing it?

Author:dquigley,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24436893/replicating-unix-kill-syntax-with-python-argumentparser
yy