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 command replies consistent with requests #24

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

macvenez
Copy link
Contributor

resolves #22

I added $ character to each command reply.
It might be unnecessary in some conditions like replies to commands with wrong number of arguments.
In general I think it's good anyway to easily distiguish between messages

@antirez
Copy link
Owner

antirez commented Oct 16, 2024

Hello @macvenez, checking your PR I think we could go the Redis protocol route. What about:

Starting the reply with "+" in case of successful reply. "-" in case of errors?
Also, please note that there is a small problem in the PR in the case of the .join() call when generating the command list.

@macvenez
Copy link
Contributor Author

Yes! That's an even better idea, I'll edit it accordingly.

Can you illustrate what's going to happen with .join?

That's an example code:

LoRaPresets = ['preset1', 'preset2', 'preset3']
result = "-Valid presets: " + ", ".join(x for x in LoRaPresets)
print(result)

Shouldn't the output be:
-Valid presets: preset1, preset2, preset3 ? I think that's a correct output, right? Am I missing something (maybe in micropython something different occurs)?
Thanks!

@antirez
Copy link
Owner

antirez commented Oct 16, 2024

Great. Thanks. The problem with join is only here AFAIK:

    send_reply("$, ".join(self.fw.keychain.list_keys()))
>>> "$, ".join(["a","b","c"])
'a$, b$, c'

@macvenez
Copy link
Contributor Author

Alright, now I see it, that should be easily fixable with:
send_reply("$"+", ".join(self.fw.keychain.list_keys()))

of course that $ should be a +

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.

Make command replies consistent with requests
2 participants