Skip to content

Messages

Doeke Zanstra edited this page May 28, 2020 · 3 revisions

Messages in ok-bash

I've tried to show messages when it makes sense. Sometimes when you really want to know what's happening, you can use the --verbose flag to see all relevant messages. If you only want to see the results, you can use --quiet.

leon:

ok: duplicate commandname 'inst' mapped to 1```

Question: why prefix with "ok:"? It seems clear that this is a message from ok? I now have this:

Duplicate named command 'inst'; mapped to 1.

I also try to detect errors in named commands (I check if a colon is in the first 20 characters). The message when found is:

Possible unrecognized named command '!ist' detected with illegal characters (mapped to 2)

Additional: I only show these warnings with the list command, not when running a command. I have some test-cases in the folder /test/external_commands/.

leon:
Ambiguous abbreviation -- i based the wording on mercurial...

ok: command 'i' is ambiguous, did you mean:
        in inst install```

The space seperated suggestions are easy to print, but I like comma-seperated and or for the last item better. Is this nitpicking?

This is what I have now:

$ ok c
Command 'colo' is ambiguous, which command did you mean:
	color.reset, color.text or color.custom

leon:
Exact match is applied to the term it matches (and we don't even notice or care that it's an abbreviation for a longer command)

> ok inst
> "HEY!!!"
HEY!!!

Nothing special here. I agree.

$ ok show-env
	show-env: set | grep "^_OK_"

leon:
And this one resolved, but gave a warning (i based the wording on mercurial)

> ok insta
ok: No such command! Assume you meant: 'install'...
> ". .\_ok.ps1" | clipp; # Install OK

Hmm, "No such command" seems a bit harsh. It's pretty clear what is meant. Also: I would only show that message when the --verbose switch is on.

$ ok show
    show-env: set | grep "^_OK_"

$ ok --verbose show
Matched argument 'show' with command 'show-env' because it was the only match
    show-env: set | grep "^_OK_"

Finally, when a command can't be resolved, I try to find some suggestions (using levenshtein algoritm with some additions). When one suggestion is found:

$ ok lits
Entered command 'lits' could not be found, suggested item:
	list

or when more than one suggestions are found:

$ ok color.tom
Entered command 'color.tom' could not be found, suggested items:
	color.custom or color.text

Error message when illegal commands are entered:

$ ok 1list #starts with the number 1
...(the usage screen)...

Unrecognized command '1list' with illegal characters.

$ ok Tëßt #using non-ASCII characters
...(the usage screen)...

Unrecognized command 'Tëßt' with illegal characters.
Clone this wiki locally