The CLI flag --application-server-address clashes for end-device list, get and set commands.
As reported on Slack by @Oliv4945
Steps to Reproduce:
% ttn-lw-cli ed get foo foo --application-server-address="server.com:8884"
What do you see now?
invalid argument "server.com:8884" for "--application-server-address" flag: strconv.ParseBool: parsing "server.com:8884": invalid syntax
exit status 255
On set commands you may see something like below, as the --application-server-address is treated as a device field, not as CLI config.
WARN grpc: addrConn.createTransport failed to connect to {localhost:8884 0 <nil>}. Err :connection error: desc = "transport: authentication handshake failed: x509: certificate is valid for remote.cli.net, not localhost". Reconnecting...
This problem was introduced when we started allowing flags to be specified with both dashes and underscores in https://github.com/TheThingsIndustries/lorawan-stack/pull/1498. As a result the flags --application_server_address (of the device) and --application-server-address (of the CLI itself) are now treated the same, and the CLI can no longer tell the difference.
What do you want to see instead?
We shouldn't have clashing flag names.
How do you propose to implement this?
We have a couple of options.
Only allow config file and env to configure the CLI API addresses. You don't want to specify these flags on every command anyway.
Renaming the the API address flags to something that won't occur in any of our entities.
Support them both, but look at the position so that something like ttn-lw-cli --application-server-address="server:8885" end-devices get foo foo --application-server-address would work.
If we go for 1 or 2, then we should make sure that the other flags are never used in entities: ca, config, help, input-format, insecure, log.level, output-format.
I'm not sure if option 3 is supported by cobra/pflag
Summary:
The CLI flag
--application-server-address
clashes for end-device list, get and set commands.As reported on Slack by @Oliv4945
Steps to Reproduce:
What do you see now?
On
set
commands you may see something like below, as the--application-server-address
is treated as a device field, not as CLI config.This problem was introduced when we started allowing flags to be specified with both dashes and underscores in https://github.com/TheThingsIndustries/lorawan-stack/pull/1498. As a result the flags
--application_server_address
(of the device) and--application-server-address
(of the CLI itself) are now treated the same, and the CLI can no longer tell the difference.What do you want to see instead?
We shouldn't have clashing flag names.
How do you propose to implement this?
We have a couple of options.
ttn-lw-cli --application-server-address="server:8885" end-devices get foo foo --application-server-address
would work.If we go for 1 or 2, then we should make sure that the other flags are never used in entities:
ca
,config
,help
,input-format
,insecure
,log.level
,output-format
.I'm not sure if option 3 is supported by cobra/pflag