Xpra: Ticket #2527: xpra help: present less options when subcommand is wrong

I usually don't remember all the xpra sub-commands. Apart from opening http://xpra.org/manual, or xpra --help | head, I cannot "easily enough" see the options.

Plain xpra --help is 597 lines, too big to navigate.

xpra help gives:

$ xpra help
xpra for python 2.7 is not installed
 retrying with python3
xpra initialization error:
 invalid mode 'help'
$ xpra wrong
xpra for python 2.7 is not installed
 retrying with python3
xpra initialization error:
 invalid mode 'wrong'

Proposal: make xpra help or xpra wrong-command to present:

$ xpra update
Usage:
	xpra start [DISPLAY]
	xpra start-desktop [DISPLAY]
	xpra upgrade [DISPLAY]
	xpra attach [DISPLAY]
	xpra detach [DISPLAY]
	xpra screenshot filename [DISPLAY]
	xpra info [DISPLAY]
	xpra control DISPLAY command [arg1] [arg2]..
	xpra print DISPLAY filename
	xpra version [DISPLAY]
	xpra showconfig
	xpra list
	xpra sessions
	xpra launcher
	xpra stop [DISPLAY]
	xpra exit [DISPLAY]
	xpra list-mdns
	xpra mdns-gui
	xpra shadow [DISPLAY]
See more options with `xpra --help`

For bonus points:



Thu, 26 Dec 2019 18:06:44 GMT - Antoine Martin: status changed

Not sure how easy it is to hook into the command line parsing code. We'll see.


Thu, 26 Dec 2019 18:27:40 GMT - stdedos:

I am only proposing it because I think it used to be like that (a year ago? a year and a half?). I don't know if you switched argparse systems, which then made it be like that and "cannot be done".

Feel free to ignore this if some of the above are not true.


Fri, 27 Dec 2019 12:15:15 GMT - Antoine Martin: status changed; resolution set

Updates:


Sun, 29 Dec 2019 20:32:18 GMT - stdedos:

Fixed in r24825:

Xpra-Python3-x86_64_4.0-r24825\xpra_cmd" sh
invalid subcommand 'sh'
Usage:
        xpra shadow [DISPLAY]
        xpra (This xpra installation does not support starting local servers.)
        xpra attach [DISPLAY]
        xpra detach [DISPLAY]
        xpra info [DISPLAY]
        xpra version [DISPLAY]
        xpra stop [DISPLAY]
        xpra exit [DISPLAY]
        xpra screenshot filename [DISPLAY]
        xpra control DISPLAY command [arg1] [arg2]..
        xpra print DISPLAY filename
        xpra showconfig
        xpra list
        xpra sessions
        xpra launcher
        xpra list-mdns
        xpra mdns-gui
        xpra
see 'man xpra' or 'xpra --help' for more details

Three nitpicks:

I am not sure why would you write it like that:

trunk/src/xpra/scripts/parsing.py:209

def get_usage():
    command_options = []
    if supports_server:
        command_options = ["start [DISPLAY]",
                           "start-desktop [DISPLAY]",
                           "upgrade [DISPLAY]",
                           ] + command_options
    if supports_shadow:
        command_options.append("shadow [DISPLAY]")
    if not supports_server:
        command_options.append("(This xpra installation does not support starting local servers.)")

and not e.g.

def get_usage():
    command_options = []
    if not supports_server:
        command_options.append("(This xpra installation does not support starting local servers.)")
    else:  # supports_server
        command_options = ["start [DISPLAY]",
                           "start-desktop [DISPLAY]",
                           "upgrade [DISPLAY]",
                           ] + command_options
    if supports_shadow:
        command_options.append("shadow [DISPLAY]")

I also don't see what is the usage of ] + command_options.


Mon, 30 Dec 2019 09:47:42 GMT - Antoine Martin:

First capital in invalid, see

r24840

Empty xpra (except if you want to emphasize that plain xpra is a valid command i.e. opens the GUI)

I do.

I am not sure why would you write it like that:

Because this code evolved from somewhere else and I was trying to minimize the changes, see r24807. r24841 addresses that, and more.


Mon, 13 Jan 2020 11:29:16 GMT - stdedos:

I guess this is not going in v3?


Mon, 13 Jan 2020 13:20:01 GMT - Antoine Martin:

I guess this is not going in v3?

No, this is not a bug fix.

This would be suitable for milestone/3.1 however.


Sat, 23 Jan 2021 05:53:41 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2527