Giter VIP home page Giter VIP logo

path-and-address's Introduction

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:

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

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

Some examples:

$ 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:

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:

$ 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

path-and-address's People

Contributors

joeyespo avatar myhro avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

myhro jwilk-forks

path-and-address's Issues

tests fails with python3.4

I: pybuild base:170: cd /tmp/buildd/python-path-and-address-1.0.0/.pybuild/pythonX.Y_3.4/build; python3.4 -m unittest discover -v
path_and_address.tests.test_validation (unittest.loader._FailedTest) ... ERROR

ERROR: path_and_address.tests.test_validation (unittest.loader._FailedTest)

Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib/python3.4/unittest/case.py", line 577, in run
testMethod()
File "/usr/lib/python3.4/unittest/loader.py", line 33, in testFailure
raise self._exception
ImportError: Failed to import test module: path_and_address.tests.test_validation
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/loader.py", line 323, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python3.4/unittest/loader.py", line 301, in _get_module_from_name
import(name)
File "/tmp/buildd/python-path-and-address-1.0.0/.pybuild/pythonX.Y_3.4/build/path_and_address/tests/test_validation.py", line 35, in
addresses = hostnames + ports + _join_all(hostnames, ports)
TypeError: can only concatenate list (not "map") to list


Ran 1 test in 0.000s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.