Yoda PA
Personal Assistant on the command line.
Installation
pip install yodapa
yoda --help
Configure Yoda
yoda configure
Plugins
Yoda is designed to be extensible. You can write your own plugins or use the AI to generate one for you.
List plugins
The help command will list all the available plugins.
$ yoda --help
Write your own plugin for Yoda
Simply create a class with the @yoda_plugin(name="plugin-name") decorator and add methods to it. The non-private
methods will be automatically added as sub-commands to Yoda, with the command being the name you provide to the
decorator.
import typer
from yodapa.plugin_manager.decorator import yoda_plugin
@yoda_plugin(name="hi")
class HiPlugin:
"""
Hi plugin. Say hello.
Example:
$ yoda hi hello --name MP
$ yoda hi hello
"""
def hello(self, name: str = None):
"""Say hello."""
name = name or "Padawan"
typer.echo(f"Hello {name}!")
def _private_method_should_not_be_added(self):
"""This method should not be added as a command."""
raise NotImplementedError()
Use AI to generate your own plugin
$ yoda ai generate-command todo "todo list that keeps track of your todos"
🤖 Generated code:
import typer
from yodapa.plugin_manager.decorator import yoda_plugin
@yoda_plugin(name="todo")
class TodoPlugin:
"""
Todo plugin. Keeps track of your todos.
Example:
$ yoda todo list --all
$ yoda todo add "Finish assignment"
$ yoda todo done 1
$ yoda todo delete 2
"""
def list(self, all: bool = False):
"""List all todos."""
if all:
typer.echo("All todos:")
for todo in self.todos:
typer.echo(f"- {todo}")
else:
typer.echo("Active todos:")
for todo in self.active_todos:
typer.echo(f"- {todo}")
def add(self, name: str):
"""Add a new todo."""
if name == "":
raise ValueError("Todo name cannot be empty")
self.todos.append(name)
typer.echo(f"Added todo '{name}'")
def done(self, id: int):
"""Mark a todo as done."""
if id < 0 or id >= len(self.todos):
raise ValueError("Todo ID out of range")
self.active_todos.remove(self.todos[id])
typer.echo(f"Marked todo {id} as done")
def delete(self, id: int):
"""Delete a todo."""
if id < 0 or id >= len(self.todos):
raise ValueError("Todo ID out of range")
self.todos.remove(self.todos[id])
typer.echo(f"Deleted todo {id}")
def __init__(self):
self.todos = []
self.active_todos = []
if __name__ == "__main__":
typer.run(TodoPlugin())
Development setup
# 1. Install poetry from their website: https://python-poetry.org/docs/#installation
# 2. Install dependencies and this package
poetry install
# 3. Activate the virtual environment
poetry shell
# Now you should be able to communicate with yoda
yoda --help
Testing
# Run tests when in the virtual environment
pytest
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yodapa-0.4.0.tar.gz.
File metadata
- Download URL: yodapa-0.4.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b860871202e5f34bbd53fa681dd5f95e74f9636ae2b7121920be3153d21ae531
|
|
| MD5 |
ccf081cb774cd1d4ad12cd1fbfa19151
|
|
| BLAKE2b-256 |
b022b67359815b39393f435a054b92321fabc461eee44c4aaa0609728a251bd4
|
File details
Details for the file yodapa-0.4.0-py3-none-any.whl.
File metadata
- Download URL: yodapa-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b4df55a41e958601f31cf1a23733f31763400de22cbf3193947b1af62e38431
|
|
| MD5 |
25b1ec475deaa0279924def4c90340e0
|
|
| BLAKE2b-256 |
24c4cf03b38aeb3119f18f9bb268a951ceea1a72896c1221def6b7985baf45fc
|