Single Executable Interface

I've recently become a fan of using a single executable type of interface for systems consisting of several related programs.

The norm for groups of executables in a system seems to be providing multiple executables for users to run for different functionality. But "single executable interface" means to provide a single executable with a generic name based on the system it is a part of, with more specific functionality accessed based on a command name passed as the first argument to this executable.

Using only a single executable can greatly simplify the use of your system of programs. Users no longer need to worry about locating and understanding the functions of several different executables, and instead only need to remember the name of a single executable for that system. In addition, all the functionality of that system can be organized under a single man page. Using a single executable also reduces path namespace pollution by only contributing a single entry to the set of executables on the path. The search path based structure of locating executables used in UNIX is very inelegant and poorly designed, but this issue is helped by using a single executable interface.

One possible issue you might notice with a single executable interface is that, by having all the code for your system in a single executable, you require all that code to be loaded or compiled each time the program is run. Even if only a fraction of that code is used in the executation of a given command. However, the single executable interface only dictates that the interface the user sees for the system consist of a single executable. This single executable could be a small script with a switch statement that calls another private executable based upon the command argument passed.

Puppet migrated to supporting a single executable interface in one of its more recent versions (although it still has the old executables for backwards compatibility). All Puppet functionality that could once be obtained through calling a specific executable for that task (i.e. "puppetca") can now be obtained by passing a command argument to the generic "puppet" executable (i.e. "puppet cert").

Even if you don't use a single executable interface for all the functionality in your system, I recommend you at least use a common prefix for all the executables provided. When a user is able to type a prefix, and then use tab completion to find all the possible executables with that prefix, it greatly simplifies locating executbales relevant to a system. One of the annoyances in using the NIS system is the lack of a common prefix, some commands begin with "yp" (i.e. "ypcat", "ypmake") while others merely contain "yp" at a later point in the name (i.e. "viyp"). This naming scheme seems very ugly and poorly thought out to me.

Tag Cloud

Find recent content on the main index or look in the archives to find all content.