sangoma / switchy

async FreeSWITCH cluster control
https://switchy.readthedocs.io/en/latest/
Mozilla Public License 2.0
69 stars 18 forks source link

Add switchy command line #9

Closed moises-silva closed 8 years ago

moises-silva commented 8 years ago

A command line is something needed if we want adoption by non Python programmers (which I think will be the majority of interested users).

These commits add a 'switchy' command with several sub-commands (like git does for 'git clone', git merge' etc)

The current sub-commands are:

list-apps (to list available apps) run (to run a load test) plot (to plot saved results)

In order to be able to list available apps and display help for users I introduced an @app decorator which applications should use. More details in the commit message ...

goodboy commented 8 years ago

Gave it a first once over.

vodik commented 8 years ago

There's a better way of doing this than adding bin/switchy btw.

Add a __main__.py file to switchy and use setuptools to generate a wrapper. Example: https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/

This is how py.test does it, and it simplifies a whole bunch of things (for example, if you need to eventually generate a switchcy2 or switchy3 script.

Otherwise looks alright.

vodik commented 8 years ago

Actually, even better, look at this project: https://github.com/mitsuhiko/click/tree/master/examples/repo

Their entry point in setup.py jumps straight into click's cli command.

goodboy commented 8 years ago

Patched a bunch of bugs / reimplemented a bunch of the apps/__init__.py stuff to handle missing optional deps. I've also manually tested the cli stuff extensively in a virtualenv (we still need unit tests for that btw - should I make an issue?). Also, force pushed a squashed down history so we get a nice small number of logical changes.

@moises-silva if you can take one more look over it that would be great before I merge.

moises-silva commented 8 years ago

overall I wished you didn't rebase things yet, makes it much harder for me to see the changes you did (checking only the diff of your commits rather than the whole rebased/reworked versions), particularly commit https://github.com/sangoma/switchy/commit/c916190991daf2535694d35a90a74e60b1eec3d7

goodboy commented 8 years ago

@moises-silva I can push the original branch if you'd like (still have a local backup) although all I really did was added was 3 commits: 1) patches to the apps loading and utils submodule importer 2) patches to the cli to match above 3) the tox.ini

Let me know.