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

Bug: username expected when publish subcommand is used even if specified #169

Open
omani opened this issue May 23, 2024 · 8 comments
Open

Comments

@omani
Copy link

omani commented May 23, 2024

mqttui publish --username mqtt test test
error: The following required arguments were not provided:
    --username <STRING>

USAGE:
    mqttui --password <STRING> --username <STRING>

For more information try --help
$ mqttui --version
mqttui 0.20.0
@omani
Copy link
Author

omani commented May 23, 2024

this worked:

mqttui -u mqtt publish --username mqtt test test

so how come I need to specify the username twice?

@EdJoPaTo
Copy link
Owner

mqttui v0.20 is not the latest version (are you using the one packaged on alpine?)

Anyway, that's something that wasn't really changed since then.

The idea here is to require both username and password or none of them.

With my version this is printed more clear:

$ mqttui publish --username mqtt test test
error: the following required arguments were not provided:
  --password <STRING>

Usage: mqttui publish --username <STRING> --password <STRING> <TOPIC> <PAYLOAD>

For more information, try '--help'.

Using mqttui v0.20 (checked out the tag and built it from there):

$ git checkout v0.20.0
…
$ cargo run -- publish --username mqtt test test
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/mqttui publish --username mqtt test test`
error: the following required arguments were not provided:
  --password <STRING>

Usage: mqttui publish --username <STRING> --password <STRING> <TOPIC> <PAYLOAD>

For more information, try '--help'.

So something is weird here as my output also differs from yours there 👀

@omani
Copy link
Author

omani commented May 27, 2024

yes Im on alpine. there was an update of the mqttui package few days ago. now I am on 0.21.0. still the same issue. I guess the alpine package is somehow different? anyway, it works when I specify the username twice as mentioned above. I can live with that.

thanks for this great tool. feel free to close this issue.

@EdJoPaTo
Copy link
Owner

A question that definitely remains: Why do you need a username without a password?

Also… it's somewhat strange that the CLI handling seems to be different on Alpine… would be interesting to find out why it's different.

@omani
Copy link
Author

omani commented May 28, 2024

I do use a password. it is in the env variable MQTTUI_PASSWORD. hence why you dont see it in my cli invocation.

good question regarding the difference in alpine. are you the maintainer of the aport?

@EdJoPaTo
Copy link
Owner

I do use a password. it is in the env variable MQTTUI_PASSWORD. hence why you dont see it in my cli invocation.

Ah, that was missing in the initial report. I will take a look into that (just not now).

good question regarding the difference in alpine. are you the maintainer of the aport?

Nope, I am not the maintainer of that package. But I would assume that it's not that far from the normal cargo build.

@EdJoPaTo
Copy link
Owner

This results from being a global option which allows the arguments to be either mqttui --here pub or mqttui pub --here. Username requires password and vice versa. As the environment variable seems to set a value in both places, the other one seems to be required in both places too. So yeah, I can reproduce this.

You could also specify the username as environment variable too, but that doesnt fix the root cause of this. MQTT Options could no longer be global, so they would need to be specified as mqttui --here pub all the time. But that seems somewhat weird too. I think this should be reported to clap, the underlying CLI library (or checked for existing issues on this first).

@omani
Copy link
Author

omani commented May 29, 2024

not sure but I think Ive found it clap-rs/clap#5020

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

2 participants