Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make aliases useful for deprecating commands #3342

Open
4 tasks
myk002 opened this issue May 2, 2023 · 9 comments
Open
4 tasks

Make aliases useful for deprecating commands #3342

myk002 opened this issue May 2, 2023 · 9 comments
Assignees

Comments

@myk002
Copy link
Member

myk002 commented May 2, 2023

The current alias system is intended to allow a player to make a shorter version of a frequently used command and/or parameter list. However, aliases have recently begun to be used as a way to allow an old name for a renamed/deprecated tool to function. The idea is that players who are used to typing the old name will still be able to do so, and renamed tools that can be enabled will still be enableable via their old name.

Aliases, however, are not well integrated into the rest of the system and do not really provide players and script writers with a good overall experience when they are used to make deprecated names "still available". Here are some ideas for improving the player experience for aliases:

  • show appropriate help in gui/launcher when the alias is in the commandline. It would also be useful to prepend the help text with the alias expansion so the player can see exactly what they will be running, though this is not required if it ends up being too difficult.
  • possibly already covered by the gui/launcher item, helpdb should display useful help text if an alias is given as an entry (this will allow help text to appear in the hotkeys logo popup menu if an alias is given a hotkey, for example). document that players should poke helpdb to reindex after modifying aliases (we probably don't want to do this automatically since aliases tend to be updated in batches (i.e. in init files) and we already reindex on world load/unload)
  • allow reqscript to find the correct script if an alias is named (e.g. reqscript('unforbid') would redirect to reqscript('claim'))
  • allow require to find the correct module if an alias is named (e.g. require('plugins.oldname') would redirect to require('plugins.newname'))

Edit: I think the ROI on those last two might be insufficient to warrant implementation.

@Penumbra69
Copy link

Taking a look at this.

@myk002 myk002 self-assigned this May 20, 2023
@myk002
Copy link
Member Author

myk002 commented May 20, 2023

do you need any help on this one? I could do this part to unblock the claim rename PRs

@jppessoap
Copy link

Hello. Could aliases be made for the commands "show" and "hide" so they include "console" or "terminal" on their name, which would better reflect what exactly is shown or hidden, making finding those commands easier?

@Penumbra69
Copy link

Apologies - I had some personal matters to deal with -- I will dig back into this.
I believe I know what needs to be done, will try to get a PR pushed asap.

@myk002 myk002 assigned Penumbra69 and unassigned myk002 May 23, 2023
@Penumbra69
Copy link

Penumbra69 commented May 26, 2023

Almost ready to push this PR -- one Q:

document that players should poke helpdb to reindex after modifying aliases

What kind of documentation are you suggesting here?

@myk002
Copy link
Member Author

myk002 commented May 26, 2023

in the alias command docs, just a line that says something to the effect of "help text is refreshed whenever a game is loaded, but if you modify alias definitions during a running game and want to enable autocomplete and help text for the alias in gui/launcher, be sure to run this command: :lua require('helpdb').refresh()"

@Penumbra69
Copy link

in the alias command docs, just a line that says something to the effect of "help text is refreshed whenever a game is loaded, but if you modify alias definitions during a running game and want to enable autocomplete and help text for the alias in gui/launcher, be sure to run this command: :lua require('helpdb').refresh()"

My implementation doesn't seem to incur this requirement, as I'm not actually changing the helpdb text, but synthesizing the alias text on top of what helpdb returns. When I add an alias in the console, gui/launcher can use it without a refresh or reload since it's using the C++ functions to test the input with.

I'll push the PR to ensure my solution meets your needs.

@myk002
Copy link
Member Author

myk002 commented May 26, 2023

In order to have the alias appear in the autocomplete list, as well as the output of ls and tags (which I realize was not clearly stated as a requirement), I'm certain you'll have to add the entry to helpdb. It will likely only take a light refactoring of logic you've added to gui/launcher. I'll take a look in the PR.

Penumbra69 added a commit to Penumbra69/dfhack that referenced this issue May 26, 2023
 - Make aliases available to lua
 - Ensure alieses typed in `gui/launcher` show proper help entry
 - Enhance help entry with aliased command information
 - added a simple set of tests
Penumbra69 added a commit to Penumbra69/dfhack-scripts that referenced this issue May 26, 2023
 - Make aliases available to lua
 - Ensure alieses typed in `gui/launcher` show proper help entry
 - Enhance help entry with aliased command information
 - added a simple set of tests
Penumbra69 added a commit to Penumbra69/dfhack that referenced this issue May 26, 2023
 - Adjusting to take in a table / vector for "addAlias"
Penumbra69 added a commit to Penumbra69/dfhack that referenced this issue May 26, 2023
 - Adjusting to take in a table / vector for "addAlias"
@Penumbra69
Copy link

I did not recognize that we wanted the alias as well to be listed - I was only solving for showing the appropriate help when an alias was detected. I will dig into this this evening.

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

No branches or pull requests

3 participants