Skip to main content

Functions for server command-line arguments used by humans.

Project description

Path-and-Address
================

Functions for command-line server tools used by humans.


Description
-----------

Path-and-address resolves ambiguities for command-line interface applications
with the following pattern:

```bash
$ your_app [<path>] [<address>]
```

The library applies [the principal of least surprise][pols] to command-line
interfaces.

Some examples:

```bash
$ your_app .
* Serving . on http://localhost:5000/

$ your_app 80
* Serving . on http://localhost:80/

$ your_app ./80
* Serving ./80 on http://localhost:5000/

$ your_app path/to/file
* Serving path/to/file on http://localhost:5000/

$ your_app 0.0.0.0
* Serving 0.0.0.0 on http://localhost:5000/

$ your_app . 0.0.0.0
* Serving . on http://0.0.0.0:5000/

$ your_app 0.0.0.0:8080
* Serving . on http://0.0.0.0:8080/
```


Usage
-----

Implement a CLI front-end in Python that exposes the above `[path] [address]`
pattern. Then call `resolve(path, address)`.

Example, using `sys.argv` directly:

```python
import sys
from path_and_pattern import resolve

path, address = resolve(*argv[1:])
```

More examples can be found in the "examples" directory.


Installation
------------

To install, simply:

```bash
$ pip install path-and-address
```

Or put it in your project's `requirements.txt`.


Contributing
------------

1. Check the open issues or open a new issue to start a discussion around
your feature idea or the bug you found
2. Fork the repository, make your changes, and add yourself to [Authors.md][]
3. Send a pull request


[pols]: http://en.wikipedia.org/wiki/Principle_of_least_astonishment
[authors.md]: ./AUTHORS.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

path-and-address-2.0.1.zip (6.5 kB view details)

Uploaded Source

File details

Details for the file path-and-address-2.0.1.zip.

File metadata

File hashes

Hashes for path-and-address-2.0.1.zip
Algorithm Hash digest
SHA256 e96363d982b3a2de8531f4cd5f086b51d0248b58527227d43cf5014d045371b7
MD5 4c9799605f1b3c0b2ecc62779ef1b205
BLAKE2b-256 2bb5749fab14d9e84257f3b0583eedb54e013422b6c240491a4ae48d9ea5e44f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page