Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreztz/cmd-parser
Command Parser Library
https://github.com/andreztz/cmd-parser
Last synced: 20 days ago
JSON representation
Command Parser Library
- Host: GitHub
- URL: https://github.com/andreztz/cmd-parser
- Owner: andreztz
- License: mit
- Created: 2023-10-01T09:25:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-24T17:51:28.000Z (3 months ago)
- Last Synced: 2024-10-04T22:41:08.318Z (3 months ago)
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# cmd-parser
[![PyPI - Version](https://img.shields.io/pypi/v/cmd-parser.svg)](https://pypi.org/project/cmd-parser)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cmd-parser.svg)](https://pypi.org/project/cmd-parser)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**
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)## Installation
You can install the Command Parser Library using pip:
```console
pip install cmd-parser
```## Usage
Here's a quick example of how to use the library:
```python
from cmd_parser.core import asdict, parsecommand_string = '!command arg1 arg2 param=True param1=1 param2=.2'
parsed_command = parse(command_string)
print(asdict(parsed_command))
```This will output:
```python
{
'command': 'command',
'args': ['arg1', 'arg2'],
'kwargs': {
'param': True,
'param1': 1,
'param2': 0.2,
}
}
```## License
`cmd-parser` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.