v0.1.0
This commit is contained in:
parent
5717f466f3
commit
83b9e1c497
16
README.md
16
README.md
@ -1,20 +1,20 @@
|
|||||||
# pargs
|
# pargv
|
||||||
|
|
||||||
Parse command line arguments into a list of args and a dict of kwargs.
|
Parse command line arguments into a list of args and a dict of kwargs.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pip install pargs
|
pip install pargv
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
By default, `pargs.parse_args()` uses `sys.argv` as command line arguments.
|
By default, `pargv.parse_args()` uses `sys.argv` as command line arguments.
|
||||||
It can be used in the following way.
|
It can be used in the following way.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pargs import parse_args
|
from pargv import parse_args
|
||||||
|
|
||||||
args, kwargs = parse_args()
|
args, kwargs = parse_args()
|
||||||
```
|
```
|
||||||
@ -22,19 +22,19 @@ args, kwargs = parse_args()
|
|||||||
The arguments to be parsed can also be specified manually:
|
The arguments to be parsed can also be specified manually:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pargs import parse_args
|
from pargv import parse_args
|
||||||
|
|
||||||
args, kwargs = parse_args(argv=['pargs.py', '--name=Pargs'])
|
args, kwargs = parse_args(argv=['pargv.py', '--name=pargv'])
|
||||||
```
|
```
|
||||||
|
|
||||||
# Specification
|
# Specification
|
||||||
|
|
||||||
`parse_args` parses arguments in the following way, assuming the following command line arguments (`sys.argv`): `['/pargs/pargs.py', 'command', 'positional', '--flag', '--optional=value', 'test', '--output-file', 'filename', '-flg', 'name', 'name2']`
|
`parse_args` parses arguments in the following way, assuming the following command line arguments (`sys.argv`): `['/pargv/pargv.py', 'command', 'positional', '--flag', '--optional=value', 'test', '--output-file', 'filename', '-flg', 'name', 'name2']`
|
||||||
|
|
||||||
By calling `args, kwargs = parse_args()`, this would return the following list and dict:
|
By calling `args, kwargs = parse_args()`, this would return the following list and dict:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
args = ['/pargs/pargs.py', 'command', 'positional']
|
args = ['/pargv/pargv.py', 'command', 'positional']
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'flag': True,
|
'flag': True,
|
||||||
'optional': ['value', 'test'],
|
'optional': ['value', 'test'],
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md') as f:
|
|||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pargs',
|
name='pargv',
|
||||||
version='0.1.0',
|
version='0.1.0',
|
||||||
description='Parse command line arguments into a list of args and a dict of kwargs.',
|
description='Parse command line arguments into a list of args and a dict of kwargs.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import pytest
|
import pytest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from pargs import parse_args
|
from pargv import parse_args
|
||||||
|
|
||||||
|
|
||||||
def test_no_argv():
|
def test_no_argv():
|
||||||
@ -75,8 +75,8 @@ def test_unintended_hyphen():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('argv, args, kwargs', ((
|
@pytest.mark.parametrize('argv, args, kwargs', ((
|
||||||
['/pargs/pargs.py', 'command', 'positional', '--flag', '--optional=value', 'test', '--output-file', 'filename', '-flg', 'name', 'name2'],
|
['/pargv/pargv.py', 'command', 'positional', '--flag', '--optional=value', 'test', '--output-file', 'filename', '-flg', 'name', 'name2'],
|
||||||
['/pargs/pargs.py', 'command', 'positional'],
|
['/pargv/pargv.py', 'command', 'positional'],
|
||||||
{
|
{
|
||||||
'flag': True,
|
'flag': True,
|
||||||
'optional': ['value', 'test'],
|
'optional': ['value', 'test'],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user