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

Support adding custom commands at compile time #200

Merged
merged 8 commits into from
Feb 9, 2024

Conversation

zuiderkwast
Copy link
Collaborator

@zuiderkwast zuiderkwast commented Feb 8, 2024

Extend gencommands.py with more flexible command handling:

  • Don't require the JSON filename to match the command name.
  • Don't require command name to be in uppercase in the JSON file.
  • Allow non-alphanumeric chars in command name.
  • Accept multiple JSON files on the command line.
  • For convenience, accept files on the format of cmddef.h as input.
  • Handle JSON files without key specs, with a fallback to using the "arguments"
    key to find the position of the first key.
  • Handle JSON files where subcommands are defined as a simple command with a
    space in the command name (instead of as a nested JSON structure).

Additionally, correct uppercase ordering of commands where the ordering would
be ambiguous if strncasecmp() would have been used (e.g. EVAL_RO vs EVALSHA).
This fixes possible failures to find such commands in the lookup table resulting
in "unknown command" errors.

Fixes #162.

Copy link
Collaborator

@bjosv bjosv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic.
alloca was for me a forgotten gem, but seems sweet in this case.

gencommands.py Outdated Show resolved Hide resolved
gencommands.py Outdated Show resolved Hide resolved
* Don't require the filename to match the command name
* Don't require command name to be in uppercase in the JSON file
* Allow non-alphanumeric chars in command name
* Correct uppercase ordering of commands where ordering would be ambiguos if
  strncasecmp would be used (e.g. EVAL_RO vs EVALSHA).
@zuiderkwast
Copy link
Collaborator Author

@selcukaltinay FYI

gencommands.py Outdated Show resolved Hide resolved
@zuiderkwast zuiderkwast merged commit b2add9f into Nordix:master Feb 9, 2024
32 checks passed
@zuiderkwast zuiderkwast deleted the custom-commands branch February 9, 2024 10:19
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.

Support custom commands defined in Redis modules
2 participants