views:

318

answers:

7

I write many scripts at home and on the job. Most of the time the scripts get used only a few times to accomplish their chosen task and then are never used again. However, sometimes I write a script to do something more complicated, something that requires user input. It is at this point that I usually agonize over whether to implement a GUI or stick with a y/n, press 1-10, etc. command-line interface. This type of interface can become tedious to use and difficult to maintain.

I know some things lend themselves to a GUI more than others, such as selecting things in a giant list. However, the time it takes to switch a command-line application to use a GUI is prohibitive. For me, it takes a good amount of time to add a GUI with even the most simple framework I can find.

I am curious if any developers have a method of determining at what point their script has grown enough to need a GUI. Or am I going about this the wrong way, should I always be writing my scripts assuming I might later add a GUI?

+9  A: 

As with many questions of this type, the answer is that it depends.

If your program/script does just one single thing by receiving a number of inputs from the user, it is better to stick with the non-GUI mode.

If the application is doing more than one thing and if you think that the user will use the application to do a lot of stuff, you may consider using a GUI.

Are you planning to distribute this program to others? Then it is better to provide a GUI.

If the users are non-technical, a GUI is a must!

Thats it.

Niyaz
On your last point, it is not always the case. Depending on if the customer is a customer or coworker. If the tool is simple enough, command-line is is usable for a coworker.
he_the_great
+3  A: 

When you want to hand your stuff over to someone else in a discoverable way. Command-line scripts are awesome because they are simple and elegant, but they are not very discoverable. That is, if you were to hand your scripts over to someone else with no documentation, would they be able to figure out what they are and how to use them? If your tasks are so simple that myscript /? will explain what you need to do fully, then you don't need a GUI.

If on the other hand, you are handing your scripts over to someone who isn't so technical, or needs some more visual guidance about the task to be done, than by all means, a GUI is a good way to go. You might even want to keep your scripts as they are and just create a separate GUI that runs them for maximum flexibility.

Dave Markle
+10  A: 

This doesn't answer your question but FWIW an intermediate step, between UI and command-line, is to have a configuration file instead of a UI:

  1. Edit the configuration file
  2. Run the program

A configuration file format can, if necessary, be complicated and well-commented.

ChrisW
+2  A: 

I think this decission also depends on the audience who will be using your script: If it is people who are comfortable working with the command line, then there is not pressing need to add a GUI as long as your script has a good /help which explains all the parameters it accepts. But if you want the "average user" to be able to use your program, I'd rather add a GUI because otherwise your program might not be intuitive enough for that user group.

ISW
+1  A: 

If you only need some "Dialogs" to improve your scripts, you can use KDE Kdialog or Gnome Zenity.

sebthebert
A: 

I can't count the number of times I've written what I thought would be a 'one-off' and it became more useful than I thought and ended up writing a GUI for it, or I've need to come back to use a program months later. The advantage of the GUI is it makes it easier to remember what would otherwise likely be command line arguments. I.e. for flags and options you can simply use check boxes, combo boxes, radio buttons, and file selectors filenames. I use Borland C++ RAD so it is quite quick and easy to throw together a simple (or even not so simple) dialog box. I now often start with creating the GUI.

Roger Nelson
A: 

If you use Linux, try Zenity. It's an easy to use tool to make a GUI for command-line programs.

mdm