Question: What do users prefer? When should text be read from the keyboard?
matrix-commander.py --image img.png and matrix-commander.py --file doc.pdf and similar commands without -m prompt the user for a message text input and then send the image/file/etc and the message at the end.
That is like that by design. And is documented as such.
If there is no message whatsoever (no -m), then matrix-commander will try to read one from stdin, and if there is no message piped in via stdin, then matrix-commander prompts for a message on the keyboard. Same for -i, --f, -e, etc.
Documentation says: use -m "" to avoid being asked for a message, to avoid sending a message.
Historically speaking the original idea was, the user just types matrix-commander.py without any arguments and that is short and simple for sending a trivial text message. The user sits at the terminal has an alias mc to matrix-commander.py and in order to fire off a text message, the user just types mc and that is it. From that history, this logic stuck.
But I do understand the contrary viewpoint. The alternative is: the user must nearly always use -m to be able to send a text or pipe some text into matrix-commander. matrix-commander.py -i img.jpg instinctively means "just send an image, send no text". In the alternative view, it would just do that, send one image, no text. (But currently it will prompt for a text.) In the alternative way, there are only 2 ways to send a message: matrix-commander.py -m foo and echo foo | matrix-commander.py. And it would only go and read from the keyboard if there is nothing else to do. Pretty much matrix-commander.py is the only time it would go and prompt for a text on the keyboard.
I am sort of hesitant to make an incompatible changes. I am not sure what is better.
- What do you users think is the preferred way to handle this?
- Who has noticed? Who has a preference?
- What is your preference?
- Why is this your preference?
Any feedback is welcome.
I am in favor of only reading STDIN if no other transmission (-i, -m, etc.) was specified, or if some specific flag is passed (I would probably look for -m - myself).
I have actually run into a problem where MC hangs trying to read from STDIN even when passed a message with -m when called from a Perl script that was manipulating STDIN in some way. I patched it locally to stop it from attempting to open the pipe at all if a message was specified on the command line, but didn't make a pull request because I wasn't sure if that would be what others would want.
@edwinsage Thanks for the feedback :clap:. That is 1 vote in favor of "the alternative", reading STDIN only if no other transmission (-i, -m, -f, -e, etc) is specified.
@ other people: pleae chime in and give your opinion.
-
mcand the "original way" are good for frequent usage. - Otherwise, the "alternative way" is natural,
mcis not needed and the user's scripts may callmcto mean the famous Midnight Commander. - Most short names are taken by well-known software.
/usr/bin/mcis Midnight Commander since at least 1999 (if not before). It is in the mainstream Linux distributions (example) and can be called from CLI. So- a user's script or a configuration to choose the file manager may call
mcto mean Midnight Commander. - if matrix-commander is published in any Linux repo, either it will be made uninstallable alongside mc, or its
mcwill be removed.
- a user's script or a configuration to choose the file manager may call
What if mc is created by the user to opt-in to the "original way".
- GitHub: Do not have
mc - Documentation:
- default to the "alternative way"
- instructions to enable the "original way": make a symbolic link named
mcin/usr/local/bin/or$HOME/.local/bin/so typingmcwithout the path will be sufficient (as prescribed by the XDG spec).ln -s /.../matrix-commander.py $HOME/.local/bin/mc
- matrix-commander.py:
PROG_WITH_EXT = sys.argv[0] # This is the name typed by the user. if os.path.basename(PROG_WITH_EXT) == 'mc'`: do the "original way" else: do the "alternative way" - The incompatible change is for user interaction, so the user is informed anyway. What about printing a deprecation warning for a few versions?
@opk12 I interpret your comment as a vote in favor of "the alternative", i.e. reading STDIN only if no other transmission (-i, -m, -f, -e, etc) is specified. That makes a total of 2 votes in favor of "the alternative".
Regarding, mc. I will remove the soft link mv-->matrix-commander.py from Github (I had put it there only a day or two ago). It should be up to the user to make an alias, a soft link or whatever, iff they want to.
See commit 0ccd985
See commit comments. "The alternative" is implemented. It reads from keyboard only if there are no other actions.
Seems ok from a cursory glance; in the CLI options documentation, maybe the repeated parts for -m -i ... could go in the general description block (Welcome to matrix-commander...).
Thanks @opk12 , your feedback is valid. In general, the documentation is a bit repetitive, as well as a bit too wordy. I am aware of that. But when it comes to the specifics of the options like -i or -m I'd rather have it repetitive because I feel that (due to the length) people do not read the general description above, but just read the option that they are interested in. So, in short, while repetitive I hope it helps the user. I will more or less leave it as-is.
Closing this issue, please re-open if something new comes up. Or add further comments.