The cmd-parser
library provides a simple way to parse command-line style input strings into a structured dictionary format. This is useful for applications that need to interpret commands with arguments and parameters.
Table of Contents
You can install the Command Parser Library using pip:
pip install cmd-parser
Here's a quick example of how to use the library:
from cmd_parser.core import asdict, parse
command_string = '!command arg1 arg2 param1="value1 test" param2=value2'
parsed_command = parse(command_string)
print(asdict(parsed_command))
This will output:
{
'command': 'command',
'args': ['arg1', 'arg2'],
'kwargs': {
'param1': 'value1 test',
'param2': 'value2'
}
}
cmd-parser
is distributed under the terms of the MIT license.