Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Made the examples actually use Clint.
Browse files Browse the repository at this point in the history
  • Loading branch information
brownhead committed Nov 5, 2013
1 parent 2a890e6 commit 9d06f66
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ The ``setup.py`` file establishes the Clint dependency and is very short. This f
from setuptools import setup, find_packages
setup(
name = "tinyscript",
packages = find_packages()
packages = find_packages(),
install_requires = ["Clint"]
)
The ``__init__.py`` file is empty (see `here <http://stackoverflow.com/questions/448271/what-is-init-py-for>`_ for info).
Expand All @@ -35,18 +36,19 @@ Finally, the ``main.py`` file has our actual script.
.. code-block:: python
# main.py
from clint.textui import puts, colored
import sys
def foo():
print "I am a mighty foo function!"
puts(colored.red("I am a mighty foo function!"))
sys.exit(0)
def bar():
print "Nice to meet you, I am bar."
puts(colored.blue("Nice to meet you, I am bar."))
sys.exit(1)
if __name__ == "__main__":
print "Running as a script!"
puts("Running as a script!")
sys.exit(2)
We can now use Super Zippy.
Expand All @@ -63,6 +65,8 @@ We can now use Super Zippy.
$ echo $?
0
*Note that "I am a mighty foo function!" above is displayed in red if you actually run it.*

If we'd like to have the ``bar()`` function be our entry point (rather than the ``foo()`` function above), we could run

.. code-block:: shell
Expand Down
3 changes: 2 additions & 1 deletion examples/readme/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
from setuptools import setup, find_packages
setup(
name = "tinyscript",
packages = find_packages()
packages = find_packages(),
install_requires = ["Clint"]
)
7 changes: 4 additions & 3 deletions examples/readme/tinyscript/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/env/bin python

from clint.textui import puts, colored
import sys

def foo():
print "I am a mighty foo function!"
puts(colored.red("I am a mighty foo function!"))
sys.exit(0)

def bar():
print "Nice to meet you, I am bar."
puts(colored.blue("Nice to meet you, I am bar."))
sys.exit(1)

if __name__ == "__main__":
print "Running as a script!"
puts("Running as a script!")
sys.exit(2)

0 comments on commit 9d06f66

Please sign in to comment.