please-cli: Solving man Pages With AI
Large Language Models (LLMs) like GPT-4 are trained on vast datasets that include man pages, readmes, forum questions and discussions, source code and other sources of command line tool documentation. Given a set of requirements one can query a LLM to predict a command line that will perform the required task.
please-cli is a wrapper around GPT-4 that can help you translate your requirements into a shell command. Let’s start with an example:
benjamin@asterix:~# please convert a.jpeg to avif and upscale it to 200% |
Well, looks promising and the code actually works. please-cli also gives you some handy shortcuts to immediately invoke or copy the code. You can also inquire directly about the command.
In the following sections we will look at some other examples and wether we can find limitations of the script generation.
AI Assisted Shell Commands
Let’s see how well the please-cli generated command lines are for different use cases.
File Management
Handling files is a common shell task but one can easily forget certain switches or a more complex syntax. A simple example could be:
benjamin@asterix:docker-builder-container# please list the current directory contents sorted by size and display the size human readable |
The command was correct and it also worked. I pressed the I
key when prompted so please-cli invoked the generated command for me.
Now for something more complex: making directories accessible again. I tend to need this command sometimes but always forget the syntax with the curly brackets.
benjamin@asterix:~# please find all subfolders and add the execution flag for user and group |
Ok, nice. please-cli even got the permissions right and didn’t add any other permissions than the ones requested.
Container Management
Next up: container management. Can it start a docker container?
benjamin@asterix:~# please start a docker mysql container with a loop mount to the data |
Not with this query. The bind mount is ok but the detach flag is specified twice and the tag is wrong. But a slight improvement of the query fixes both problems:
benjamin@asterix:~# please start a docker mysql container with a loop mount to the data. the container is named mysql |
There we go, now it works. This goes to show that the better your query is, the better the resulting command line.
Lastly, something that one will probably not use that often: flux reconciling from source on the demo namespace.
benjamin@asterix:~# please reconcile from source on the demo namespace |
That was not enough information. Let’s try with a bit more detail:
benjamin@asterix:~# please flux reconcile from git repo on the demo namespace |
Well, if your repo is named demo, then this command should work. Again, the more information you provide, the better the result.
Giving ffmpeg a Natural Language Interface With AI
FFmpeg is a very powerful media converter, streamer and recorder. But its command line can be daunting. The huge range of codecs, plugins, filters, etc…, each with their own switches is hard to remember. Let’s see how please-cli fares:
benjamin@asterix:~# please convert a.avi to h264 with preset slow and matroska container, copy the audio |
The code works and all required settings are made. How about flags and some more exotic use cases:
benjamin@asterix:~# please convert the rtmp stream at 0.0.0.0:3334/live/stream to an hls stream with independent segments. the codec is h264 with preset ultrafast and a max rate of 3M and no audio |
Yes, works as well. Quite convenient, especially if you don’t need ffmpeg that often and always forget how to use it.
Conclusion
please-cli is a neat tool. It can save you loads of time reading through man pages or searching the web for the right syntax or switch to get your desired result. As always with current LLMs: the more specific you ask, the better the answer will be. Prompt engineering is not booming for no reason.