klenwell / dr-george

MIT License
0 stars 0 forks source link

Interactive command line interface. #3

Open klenwell opened 1 week ago

klenwell commented 1 week ago

Overview

Build the basic app framework using the Python Cement framework for command line interfaces (CLI). When complete, should be able to run a basic command like this and be dropped into an interactive console:

python main.py interactive

Acceptance Criteria

References

klenwell commented 1 week ago

Python Install

I already have pyenv installed. But I didn't have latest stable version of Python available in it. So I needed to update then install it:

$ pyenv update
$ pyenv install 3.12.6
klenwell commented 1 week ago

Cement Install

$ pip install cement
$ cement --help
usage: cement [-h] [-d] [-q] [-v] {generate} ...
klenwell commented 1 week ago

Generate Cement App

Cement expects you to generate a project from scratch and to create the project directory itself. Since I already had a directory set up, I ran the command a little differently:

# generate the app in my existing dir and use -f to overwrite any existing files (otherwise will throw an error on conflict)
$ cement generate project -f .

$ pip install -r requirements.txt 

# setuptools no longer comes prepacked with Python: https://stackoverflow.com/a/16511140/1093087
$ pip install -U pip setuptools
$ python setup.py install

I'm still having some issues running my new app. I'll address those in their own comment.

klenwell commented 1 week ago

Cement Errors

When I try to run the command line command from Cement docs, I get this:

$ dr_george_app --help
dr_george_app: command not found

When trying to run the file directly like I've done in other Cement apps, I get this error:

~/projects/dr-george$ python dr_george_app/main.py 
Traceback (most recent call last):
  File "/home/klenwell/projects/dr-george/dr_george_app/main.py", line 4, in <module>
    from .core.exc import DrGeorgeAppError
ImportError: attempted relative import with no known parent package

Resolved

Need to install the dev packages:

~/projects/dr-george$ pip install -r requirements-dev.txt 
~/projects/dr-george$ dr_george_app --help
usage: dr_george_app [-h] [-d] [-q] [-v] {command1} ...