Skip to content

Commit

Permalink
Merge pull request #5 from Gumnos/master
Browse files Browse the repository at this point in the history
A changeset to tweak cmd.py to command_line.py
  • Loading branch information
storborg committed Nov 29, 2012
2 parents 25f4447 + ca2b89b commit 522bc8f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions command-line-scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ In this case, we'll add a new file and function to support the command line tool
funniest/
funniest/
__init__.py
cmd.py
command_line.py
...
setup.py
...

The ``cmd.py`` submodule exists only to service the command line tool (which is a convenient organization method)::
The ``command_line.py`` submodule exists only to service the command line tool (which is a convenient organization method)::

import funniest

Expand All @@ -70,16 +70,16 @@ The ``cmd.py`` submodule exists only to service the command line tool (which is
You can test the "script" by running it directly, e.g.::

$ python
>>> import funniest.cmd
>>> funniest.cmd.main()
>>> import funniest.command_line
>>> funniest.command_line.main()
...

The ``main()`` function can then be registered like so::

setup(
...
entry_points = {
'console_scripts': ['funniest-joke=funniest.cmd:main'],
'console_scripts': ['funniest-joke=funniest.command_line:main'],
}
...
)
Expand All @@ -89,7 +89,7 @@ Again, once the package has been installed, we can use it in the same way. Setup
This method has the advantage that it's very easily testable. Instead of having to shell out to spawn the script, we can have a test case that just does something like::

from unittest import TestCase
from funniest.cmd import main
from funniest.command_line import main

class TestConsole(TestCase):
def test_basic(self):
Expand Down
12 changes: 6 additions & 6 deletions everything.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Our whole package, for reference, looks like this::
funniest/
funniest/
__init__.py
cmd.py
command_line.py
tests/
__init__.py
test_joke.py
test_cmd.py
test_command_line.py
MANIFEST.in
README.rst
setup.py
Expand All @@ -22,9 +22,9 @@ Here is the contents of each file:

.. literalinclude:: funniest/funniest/__init__.py

**funniest/cmd.py**
**funniest/command_line.py**

.. literalinclude:: funniest/funniest/cmd.py
.. literalinclude:: funniest/funniest/command_line.py

**funniest/tests/__init__.py**

Expand All @@ -34,9 +34,9 @@ Here is the contents of each file:

.. literalinclude:: funniest/funniest/tests/test_joke.py

**funniest/tests/test_cmd.py**
**funniest/tests/test_command_line.py**

.. literalinclude:: funniest/funniest/tests/test_cmd.py
.. literalinclude:: funniest/funniest/tests/test_command_line.py

**MANIFEST.in**

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 522bc8f

Please sign in to comment.