jsdelivr / globalping-cli

A simple CLI tool to run networking commands remotely from hundreds of globally distributed servers
Mozilla Public License 2.0
129 stars 14 forks source link

Confusing precedence behaviour "--from loc" vs "from loc" #38

Closed didil closed 1 year ago

didil commented 1 year ago

While working on https://github.com/jsdelivr/globalping-cli/issues/16 I noticed that contrary to what I implemented yesterday for the http flags (flags take precedence over what is in the "query/target" field), when running the command ping google.com from vietnam --from georgia, this ping is made from vietnam. I'm not sure if this by design ?

jimaek commented 1 year ago

from and --from are the same thing, they should be treated as duplicate parameter probably. Not sure how setting a parameter and it's alias is treated in other tools.

didil commented 1 year ago

The way the cli library we use (cobra) parses flag arguments, the latest value overwrites previous ones

But this isn't something we can do easily for the from field as one value comes for a flag argument and the other is parsed separately from the "query/target" field

jimaek commented 1 year ago

If its not easy to standardize it then I think we can just keep the current logic with Vietnam as final location