DEV Community

Cover image for What if there was a CLI called "py" that got you working right away?
Brantley Harris
Brantley Harris

Posted on

What if there was a CLI called "py" that got you working right away?

I'm tired of dealing with runtimes and virtual environments and remembering how to get everything set up for various projects, and I've been programming Python for 20 years now, I don't even understand how novice devs get along these days.

Scaffolding

In learning science, there is an idea of "scaffolding". This is a way of teaching that crosses the gap between providing rails or crutches, which make learners depend on the tools, often unable to move beyond them; and free form, which leaves learners out by themselves, often paralyzed by the possibilities. Scaffolding finds a good center where learners and pros-alike can get their bearings, pick comfortable directions, and feel supported along the way.

Two great ways to perform scaffolding are one, to provide examples, which can be taken wholly at first, and then deviated from; and also through an emphasis on goal-setting, which lets learners see clearly their paths ahead of them.

What does this have to do with a python CLI you might wonder? Well, that's exactly the issue: it doesn't usually. But what if we made a CLI that embraced scaffolding. And so here is my goal, to experiment with a different kind of CLI that works with goals and examples.

Introducing Py

Of course, all of this is ephemeral at this point; I haven't created it yet, but I've begun experimenting and I'd love to know what people think.

Py has two modes of running:

Firstly, a user-friendly CLI to run python programs; setup/install projects, environments, and runtimes; run recipes of all sorts; and generally be a very simple hub of activity for any sort of python-related tasks. But most importunately does this while negotiating virtual environments and runtimes cleanly.

This first mode would certainly step on some toes of some great projects like pyenv and poetry, but would rather use them rather than make them obsolete.

The second mode of running would be if you just typed in "py". This is where the scaffolding comes into play. Instead of seeing a crufty help screen, you would see something of a screen like this:

The PY command-line client opens and shows a menu of goals for the user to proceed with

Thanks to Rich for the wonderful interface API. With Rich, we can now create much more compelling terminal user experiences, which is something I wish to leverage here.

Goals

The goals you first get might be general, they might change based on your usage, or if you are in an existing project. And maybe your school or company could customize these based on common needs. Some initial goals might be:

Initialize a new python project - Create a new project by selecting a runtime environment, e.g. python 3.10.4, creating a virtual environment, and setting up a pyproject.toml with dependencies.

Check out an existing project and prepare to run it - Clone or download an existing project and prepare your environments to run it.

Run the python shell - Run the latest python shell, IDLE, or a notebook.

View and modify your local python environments and installations - See a list of runtime environments, and potentially upgrade or edit them.

And finally Browse other goals and find more created by the community - Which I imagine as a sort of mini-pypi user-submitted catalog of goals and recipes, browsable right here in the CLI. Imagine things like "Start a new data-science project" or even "Begin Sarah's machine learning tutorial #1".

Project

So if this interests you, send me some feedback. I'd love to hear if you like the idea, obstacles, etc. I don't have a lot of free time to work on this, so also if you'd like to jump in, let's go.

Top comments (0)