-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
alias command #1815
alias command #1815
Changes from 12 commits
708924e
58fd3bd
5e914d1
93eb9e1
76f8666
e9265b9
aeab9d6
5d379d1
7419e07
e5ebe00
8d26c2d
b8cac02
bf9581b
864d331
6a10839
116ceea
a5abf97
637aa66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,11 @@ using mod_t = interaction_bind_t::ModifierKeys; | |
|
||
class interactor_impl::internals | ||
{ | ||
//------------------------------------------------------------------- | ||
private: | ||
// Map to store aliases | ||
std::map<std::string, std::string> aliasMap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put that at the end of this class, next to the command map There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
//------------------------------------------------------------------- | ||
public: | ||
struct BindingCommands | ||
{ | ||
|
@@ -817,7 +822,31 @@ bool interactor_impl::triggerCommand(std::string_view command) | |
return true; | ||
} | ||
|
||
const std::string& action = tokens[0]; | ||
std::string action = tokens[0]; | ||
|
||
// Handle Alias Command | ||
if (action == "alias") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think i did it correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
{ | ||
if (tokens.size() != 3) | ||
{ | ||
log::error("Alias command requires exactly 2 arguments: alias <name> <command>"); | ||
return false; | ||
} | ||
const std::string& aliasName = tokens[1]; | ||
const std::string& aliasCommand = tokens[2]; | ||
aliasMap[aliasName] = aliasCommand; | ||
log::info("Alias added: ", aliasName, " → ", aliasCommand); | ||
return true; | ||
} | ||
|
||
// Resolve Alias | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unless Im mistaken this should be done even before tokenizing. |
||
auto aliasIt = aliasMap.find(action); | ||
if (aliasIt != aliasMap.end()) | ||
{ | ||
action = aliasIt->second; | ||
log::info("Alias resolved: ", action); | ||
} | ||
|
||
try | ||
{ | ||
// Find the right command to call | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the one in the internals instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done