Skip to content

Commit

Permalink
Add PyPi package
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrob committed Jul 3, 2023
1 parent be2ef92 commit fb66d9c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ Tooey is similar to (and inspired by) [Gooey](https://github.com/chriskiehl/Gooe

![Running a command line script with the Tooey decorator (sample)](https://github.com/simonrob/tooey/assets/934006/c8c53abd-e4b3-4803-a42c-f3bffa409455)


## Installation
Install Tooey from [PyPi](https://pypi.org/project/tooey/) via `pip`:

```console
python -m pip install tooey
```


## Getting started
Decorate your script's [argparse](https://docs.python.org/3/library/argparse.html) function with `@Tooey`, then run the script with or without any of its arguments.
You'll be prompted interactively in the terminal to enter each argument.
After this the script will continue as normal.


## Example
The following python script requests and then prints three arguments.
The method that handles command line arguments is decorated with `@Tooey`.
Expand All @@ -37,15 +47,24 @@ main()
Tooey automatically turns this into an interactive prompt for each argument.
![Running a command line script with the Tooey decorator (full)](https://github.com/simonrob/tooey/assets/934006/a48d6499-04d2-42d1-91e3-f8d6db219266)


## Configuration
Tooey will automatically inject itself into any decorated functions whenever `sys.isatty()` is `True`.

If you would like to override this behaviour and disable Tooey when running a script, add the additional parameter `--ignore-tooey` when running.
If you would like to override this behaviour and disable Tooey when running a script, add the additional parameter `--ignore-tooey` when running, or set an environment variable `IGNORE_TOOEY`.
For example, Tooey will ignore any decorated methods in this script:

```console
$ python tooey_example.py val1 --named-choices 1 3 --ignore-tooey
```

Conversely, if you would like to force Tooey to inject itself into decorated functions even when it does not detect a terminal-like environment, add the additional parameter `--force-tooey` when running, or set an environment variable `FORCE_TOOEY`.
For example, Tooey will still run in the following script:

```console
$ FORCE_TOOEY=1 python tooey_example.py val1 --named-choices 1 3 | sort
```


## License
[Apache 2.0](https://github.com/simonrob/tooey/blob/main/LICENSE)
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os

import setuptools

NAME = 'tooey'

about = {}
working_directory = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME)
with open(os.path.join(working_directory, '__version__.py')) as version_file:
exec(version_file.read(), about)

with open('README.md') as readme_file:
readme = readme_file.read()

# https://setuptools.pypa.io/en/latest/references/keywords.html or https://docs.python.org/3/distutils/apiref.html
setuptools.setup(
name=NAME,
version=about['__version__'],
description=about['__description__'],
long_description=readme,
long_description_content_type='text/markdown',
author=about['__author__'],
author_email=about['__author_email__'],
url=about['__url__'],
project_urls={
'Bug Tracker': '%s/issues' % about['__url__'],
'Source Code': about['__url__'],
},

packages=[NAME],
package_data={'': ['LICENSE']},
include_package_data=True,

license=about['__license__'],
classifiers=about['__classifiers__']
)
12 changes: 12 additions & 0 deletions tooey/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@
__url__ = 'https://github.com/simonrob/tooey'
__copyright__ = 'Copyright (c) 2023 Simon Robinson'
__license__ = 'Apache 2.0'
__classifiers__ = [ # https://pypi.org/classifiers/
'Development Status :: 4 - Beta',
"Operating System :: OS Independent",
'Environment :: Console',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Intended Audience :: Developers',
'Topic :: Terminals',
'Topic :: Desktop Environment',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: Apache Software License'
]

0 comments on commit fb66d9c

Please sign in to comment.