Rapidly develop GUI for command line

This post seems to ask almost exactly what you want.

The top solution of using YAD seems to cover your requisites.

For example the following one liner:

data="$(yad --title="Desktop entry editor" --text="Simple desktop entry editor" --form --field="Type:CB" --field="Name" --field="Generic name" --field="Comment" --field="Command:FL" --field="Icon" --field="In terminal:CHK" --field="Startup notify:CHK" "Application" "Name" "Generic name" "This is the comment" "/usr/bin/yad" "yad" FALSE TRUE --button="WebUpd8:2" --button="gtk-ok:0" --button="gtk-cancel:1")"

creates a dialog containing:

that looks like:

enter image description here

The output is all put on yad stdout and echo "$data" looks something like:

Application|Name|Generic name|This is the comment|/usr/bin/yad|yad|FALSE|TRUE|

Now you can "parse" the output with some cmdline tool such as cut or awk:

a="$(echo "$data" | cut -d"|" -f1)"
b="$(echo "$data" | cut -d"|" -f1)"

Then there is just application logic left to you.

Ubuntu install:

sudo add-apt-repository ppa:webupd8team/y-ppa-manager
sudo apt-get update
sudo apt-get install yad

EDIT: focusing on the convertion of GUI to command line options

After receiving a downvote, I think I interpreted the answer the wrong way. The key point he wants is conversion from GUI to cmdline options interface.

I do not know of an existing solution, and since after 7 bounty days still no answer, we can assume that there is no existing solution.

Therefore, the best we can do is help the OP create a solution himself. I believe that since there are not that many command line option cases, a reasonably small script will be sufficient.

Here goes a Python + Tk example

#!/usr/bin/env python

import Tkinter
import tkFileDialog

class Option(object):
    def __init__(self, optype, name, widget=Tkinter.Entry):
        self.optype = optype
        self.name = name
        if self.optype == 'switch':
            self.widget = Tkinter.Checkbutton
        else:
            self.widget = widget

## INPUT -------------------------------------------------------
options = [
    Option("key-value", "--text="),
    Option("switch", "-s"),
    Option("positional", "pos0"),
    Option("positional", "pos1", tkFileDialog.askopenfilename),
]
## END -------------------------------------------------------

def askopenfilename(filename):
    filename.set(tkFileDialog.askopenfilename())

# Build command
def ok_func():
    cmd = "cmd_line"
    for option in options:
        if option.optype == "key-value":
            val = tkvars[option.name].get()
            if val:
                cmd += ' '
                cmd += '%s"%s"' % (option.name, val)
        elif option.optype == "switch":
            cmd += ' '
            if tkvars[option.name].get() == 1:
                cmd += option.name
        elif option.optype == "positional":
            val = tkvars[option.name].get()
            if val:
                cmd += ' '
                cmd += val
    print cmd


tkvars = {}
app = Tkinter.Tk()
grid = Tkinter.Frame()
row = 0

# Build GUI
for option in options:
    Tkinter.Label(grid, text=option.name).grid(row=row, column=0, sticky='W')
    if option.widget == Tkinter.Entry:
        tkvars[option.name] = Tkinter.StringVar()
        widget = Tkinter.Entry(
            grid,
            textvariable=tkvars[option.name]
        )
    elif option.widget == Tkinter.Checkbutton:
        tkvars[option.name] = Tkinter.IntVar()
        widget = Tkinter.Checkbutton(
            grid,
            variable = tkvars[option.name],
            onvalue = 1
        )
    elif option.widget == tkFileDialog.askopenfilename:
        tkvars[option.name] = Tkinter.StringVar()
        widget = Tkinter.Button(
            grid,
            text='Browse',
            command=lambda: askopenfilename(tkvars[option.name])
        )
    widget.grid(row=row, column=1, sticky='W')
    row += 1

grid.pack()
Tkinter.Button(app, text="ok", command=ok_func).pack()
Tkinter.Button(app, text="quit", command=app.quit).pack()
app.mainloop()

To run on Ubuntu 12.04 first do:

sudo apt-get install python-tk

Screenshot:

enter image description here

Command generated for the screenshot:

cmd_line --text="asdf" -s qwer /path/to/file

Behaviour:

  • if the value of --text= is empty then it is omitted
  • switches only appear if the corresponding checkbox is checked

If you want to implement a new feature on top of that code, I recommend you do it here. If it gets good enough, lets split to a new repo and make it pip installable.