/blog/

2023 0616 Command line -like interfaces for mobile apps

Given that building command-line interfaces is cheap, a huge question I have is: what is a command line -like interface for mobile apps?

We need this because we need apps that are extendable by end users and apps that are built for niche users, like command line apps are. The cost of writing a shell script is low; the cost of writing an iPhone app is way too high.

Here’s what I’d like to see:

  • Very easy to write, more akin to Python’s argparse than a complex graphicl interface using MVC, MVVM, functional React hooks, etc. This might mean a very simple layout that’s easy to automate, eg just a list.
  • Enable very fast expert use. If the paradigm requires some training or practice to use, as with other expert systems like a terminal, emacs/vim, etc, that is ok as long as expert use is very fast. (Of course, if it’s also more user friendly than the terminal, that’s even better.)
  • Easy to expand. Even large command-line interfaces like git or kubectl can expand functionality very easily. One more subcommand doesn’t clutter the existing interface.
  • Restricting the design space is totally ok, however, green-on-black monospace ASCII is probably not the right starting point. For one, we need tappable targets.
  • The ability to edit and repeat previous command invocations. A shell’s ability to recall previous commands, search through them, and edit them before executing them again is very powerful. This is almost universally impossible in GUI apps, which is a shame. It is a true advantage that the command line has over even the most sophisticated GUI.
  • Generic background job execution. Without this, executing long running tasks is painful.

(I’ll note that the last two items were reasons that csh was adopted over Bourne shell in the 80s, despite implementing an objectively worse programming language.)

Imperfect solutions

Some solutions exist, but they all have serious problems compared to using a command line at a real keyboard.

A mobile terminal

Of course, there are already mobile terminals. I’m partial to Secure Shellfish on my iPhone, when I need it.

The most painful aspect of these are the requirement for perfect typing. SSH clients on mobile require perfect typing, because they’re designed for touch typing from a physical keyboard, but this is much harder to accomplish on a tiny mobile software keyboard.

How can we get something that feels just as fast on mobile?

iOS Shortcuts

I think Shortcuts is an attempt to create some of what makes the command-line special for iOS, but it falls short.

  • Can’t handle many generic verbs, but designed to make it easy to wrap many generic verbs into a small number of non-generic verbs.
  • Actually executing them is very painful; you don’t have infinity at your fingerprints the way you do in bash
  • Writing scripts is nothing like executing commands - maybe ok, but pretty different from normal command lines
  • The primitives available to real iOS app developers to add Shortcuts actions are infinitely rich, but the primitives available to Shortcuts users are impoverished. I’d love to see reusable Shortcuts libraries and more programming language -like functionality.
  • Shortcuts suffers from Apple’s design constraints, particularly a prohibition on running in the background, and a requirement to wait for spurious animations to complete.

Automatic forms generation

You may be able to build a generic graphical interface that is cheapish, but that isn’t really the same thing as a first-class GUI. A madlibs style GUI with dropdown boxes can work, but isn’t exactly ergonomic. phpMyAdmin is kind of like this, and so is the previously mentioned iOS Shortcuts.

To me, these always end up being disappointing; they’re less powerful than the command-line but you end up needing to learn as much as the command-line requires.

They also tend to require real MVC/MVVM programming to build anyway.

Building blocks

A few ideas that we could use as starting points.

  • Despite what I said above about automatic form generation, I am vaguely aware of some Powershell tooling that can generate interfaces like this, and it might be a useful place to explore.

  • Fuzzy file finding, like VS Code’s + p, is more useful on a tiny phone keyboard, perhaps combined with a system that detects typos.

  • Searching for a command by name, as VS Code’s + + p and macOS’s + + ?, is similar.

Responses

Webmentions

Hosted on remote sites, and collected here via Webmention.io (thanks!).

Comments

Comments are hosted on this site and powered by Remark42 (thanks!).