Naked: A Command Line Application Framework
Naked is a MIT licensed Python command line application framework that is currently in development, described as an 'early stable testing version'. It provides an executable for project generation, testing, profiling, and distribution to PyPI, alongside a Python library featuring an easy-to-use command-line string object parser and numerous Python type/method/function extensions. The current version is 0.1.32, released on November 6, 2022. The project maintains an active status with ongoing development, though users are advised to anticipate potential breaking changes.
Warnings
- breaking Naked is in 'early stable testing version' and the developers explicitly warn that 'things may break'. Users should expect potential breaking changes between minor or patch versions.
- gotcha The project lists support for Python 2.6, 2.7, and Python 3.3. While it might function on newer Python 3 versions, explicit compatibility is only guaranteed up to Python 3.3. Running on much newer Python versions (e.g., Python 3.8+) may lead to unforeseen compatibility issues, as Python 3.3 is quite old and Python 2 is end-of-life.
- gotcha Avoid naming your own Python files or modules 'naked.py' or 'Naked.py' in your project's `PYTHONPATH`. This can lead to import conflicts where Python imports your local module instead of the installed `Naked` package, causing `ModuleNotFoundError` or unexpected behavior when trying to import submodules like `Naked.commandline`.
Install
-
pip install Naked
Imports
- Command
from Naked.commandline import Command
- execute
from Naked.toolshed.shell import execute
Quickstart
import sys
from Naked.commandline import Command
# Simulate command-line arguments for demonstration
# In a real application, sys.argv would be populated by the shell.
# For example, to run this: python your_script.py hello world --print
sys.argv = ['your_script.py', 'hello', 'world', '--print']
c = Command(sys.argv[0], sys.argv[1:])
if c.cmd == 'hello' and c.cmd2 == 'world':
if c.option('--print'):
print('Hello World from Naked!')
else:
print('Hello World (without --print) from Naked!')
else:
print('Invalid command. Try: hello world --print')