Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a self-contained CLI archive #151

Open
samba2 opened this issue Feb 12, 2022 · 0 comments
Open

Provide a self-contained CLI archive #151

samba2 opened this issue Feb 12, 2022 · 0 comments

Comments

@samba2
Copy link

samba2 commented Feb 12, 2022

Disclaimer: This is more of a feature request/ product vision then a concrete action.

The fritzconnection project does a great job to provide a simple API to Fritzboxes as well as some CLI tools. I think it would be a good way forward to simplify the usage of the project as a CLI since this lowers the usage barriers.

Currently users are required to have Python environment available in which they call pip install .... In contrast, to just execute the CLI functionality, core Python comes with the zipapp package. My suggestion is to provide the user with a a self contained Python archive which just needs a recent Python interpreter to execute. To execute an imaginary fritzconnection CLI a user might just call python fritzconnection.pyz. This self-contained approach is very similar to Java fat jars which execute like java -jar myapp.jar.

The platform independent packaging via zipapp already seems to work. Here is what I did on my Windows 11 machine inside WSL 2:

# building
$ pip install . --target /tmp/myapp
$  python3 -m zipapp  -o /mnt/c/temp/app.pyz -m "fritzconnection.cli.fritzinspection:main" /tmp/myapp

# executing
$ python3 /mnt/c/temp/app.pyz  --help

This worked straight away. Also setting the password via ENV variable and running python3 /mnt/c/temp/app.pyz -i 192.168.178.1 worked. Additionally I ran the same app.pyz in the Windows 11 context and it also worked without any modifications. So the chances are quite high that the produced app archive is truly platform independent and also works e.g. on Macs.

So in my eyes there is only little to do to provide a zipapp which is platform agnostic and can be much simpler used - just download the file and execute (Python3 provided). What is left to do here would be the CI setup to build + release the app archive.

Which brings me to the next improvement. Currently, fritzconnection comes with a bunch of simple CLI tools which can be found inside the cli directory. For a zipapp a single entry point/ CLI command would be needed. To differentiate the functionalities the CLI would work with subcommands like python fritzconnection.pyz phonebook or python fritzconnection.pyz status. For this task a dedicated framework like click is probably a good choice (the functionality of plain argparse is limited)

An inspiration could be the meanwhile archived fritzctl project: https://github.com/bpicode/fritzctl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant