Skip to content

Silently accept forward slash for special commands#1937

Merged
rolandwalker merged 1 commit into
mainfrom
RW/silently-accept-forward-slash-special-commands
Jun 20, 2026
Merged

Silently accept forward slash for special commands#1937
rolandwalker merged 1 commit into
mainfrom
RW/silently-accept-forward-slash-special-commands

Conversation

@rolandwalker

Copy link
Copy Markdown
Contributor

Description

Silently accept forward slash for special commands.

  • commands such as \? can be entered as /?
  • commands heretofore without a backslash such as help can be entered as /help

Thus all special commands can be entered, uniformly, with an introductory forward slash, yet \dt can remain available, similar to Postgres, and plain exit can remain, similar to the vendor MySQL client.

This helps both new learners and those with muscle memory.

The only limitation to the introductory forward slash is that MyCli could never use /* (comment-start) as a special command.

For trailing commands, there is also a limitation. Trailing commands such as \edit cannot also be entered as /edit, since a string can be an expression, which is valid SQL:

select 1 as edit group by 2/edit;

SpecialCommand already had a "hidden" property, which is used here to keep the forward-slash forms from being advertised in help, so they can be considered to be experimental. However, the plan would be to advertise the forward-slash forms quite soon in MyCli 2.x. Hidden forward-slash commands are also still completable.

Some small incidental improvements are made to the detection of special commands by case, and on the acceptance of /? <term> for help on a term.

Motivation: the forward slash has become something of an industry standard for out-of-band commands, consistent across modern applications such as Slack, Codex, or Claude. It also has a long heritage in, for example, IRC. On most keyboards, it is easier to type than the backslash.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Jun 19, 2026
@rolandwalker rolandwalker force-pushed the RW/silently-accept-forward-slash-special-commands branch from 0dfe017 to 7fcfca0 Compare June 19, 2026 12:59
 * commands such as "\?" can be entered as "/?"
 * commands heretofore without a backslash such as "help" can be entered
   as "/help"

Thus all special commands can be entered, uniformly, with an
introductory forward slash, yet "\dt" can remain available, similar to
Postgres, and plain "exit" can remain, similar to the vendor MySQL
client.

This helps both new learners and those with muscle memory.

The only limitation to the _introductory_ forward slash is that MyCli
could never use "/*" (comment-start) as a special command.

For _trailing_ commands, there is also a limitation.  Trailing commands
such as "\edit" cannot also be entered as "/edit", since a string can be
an expression, which is valid SQL:

    select 1 as edit group by 2/edit;

SpecialCommand already had a "hidden" property, which is used here to
keep the forward-slash forms from being advertised in "help", so they
can be considered to be experimental.  However, the plan would be to
advertise the forward-slash forms quite soon in MyCli 2.x.  Hidden
forward-slash commands are also still completable.

Some small incidental improvements are made to the detection of special
commands by case, and on the acceptance of "/? <term>" for help on a
term.

Motivation: the forward slash has become something of an industry
standard for out-of-band commands, consistent across modern applications
such as Slack, Codex, or Claude.  It also has a long heritage in, for
example, IRC.  On most keyboards, it is easier to type than the
backslash.
@rolandwalker rolandwalker force-pushed the RW/silently-accept-forward-slash-special-commands branch from 7fcfca0 to 431c647 Compare June 19, 2026 15:46
@rolandwalker rolandwalker merged commit fddea11 into main Jun 20, 2026
11 checks passed
@rolandwalker rolandwalker deleted the RW/silently-accept-forward-slash-special-commands branch June 20, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants