Skip to content

[feature] Allow users to search by name or ip#100

Merged
gilbert-sci merged 3 commits intomainfrom
gilbert/find-by-name
Apr 17, 2025
Merged

[feature] Allow users to search by name or ip#100
gilbert-sci merged 3 commits intomainfrom
gilbert/find-by-name

Conversation

@gilbert-sci
Copy link
Copy Markdown
Contributor

@gilbert-sci gilbert-sci commented Apr 16, 2025

Summary

Users have requested that it would be nice to just search by the device name, not only the IP. This removes the uri positional arguments for the CLI and adds the option of --uri with either or

Usage

python3 synapse/cli/__main__.py --uri <device_name/device_ip> info

@maxhodak
Copy link
Copy Markdown
Contributor

it's super easy to automatically detect whether the string is an ip or a name (i.e., just check for the presence of a .). this shouldn't need to be specified explicitly

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

@maxhodak good point I'll update it to be uri

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

Funny enough I had that in the previous version lol

@gilbert-sci gilbert-sci requested a review from maxhodak April 16, 2025 18:13
@maxhodak
Copy link
Copy Markdown
Contributor

are there reasons to make it a flag rather than positional? first argument could just always be uri; you always need one, and it changes less often than the method you're calling (which should be the second positional argument)

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

@maxhodak I thought that as well, but there are actually commands that don't need a uri, like discover and plot. I mentioned this to @namthor9 but it isn't super clean to support the conditional synapsectl because we also support commands that don't need a uri (but since they are all the same entry point, anything where we have a positional arguments will be interpreted as a subcommand).

I figure that the extra --uri is a decent compromise.

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

And to be explicit, the reason why people want that ordering is because then you can easily do from the terminal:

synapsectl --uri <name> info

# up arrow, backspace
synapsectl --uri <name> start

rather than moving back and switching the command.

@maxhodak
Copy link
Copy Markdown
Contributor

oh i see, basically if the first argument is not command then none of the arguments can be positional anymore. so we are weighing having to type --uri all the time vs needing to seek the cursor further back each invocation. hmm

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

Yes. This was a suggestion from a few of our internal users, but if there is more elegant way to solve this then I'm all ears

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

We could take the time to make a more proper and persistent TUI.

@maxhodak
Copy link
Copy Markdown
Contributor

ok don't let me hold this up

@polymerizedsage
Copy link
Copy Markdown
Contributor

polymerizedsage commented Apr 16, 2025

And to be explicit, the reason why people want that ordering is because then you can easily do from the terminal:

synapsectl --uri <name> info

# up arrow, backspace
synapsectl --uri <name> start

rather than moving back and switching the command.

AFAIK you can still do

synapsectl <name> read

without --uri with your changes. The old code still included the option to have a flag its just not strictly necessary. I tested locally and it worked just fine. Maybe im missing something.

Comment thread synapse/cli/__main__.py
Comment thread synapse/cli/__main__.py Outdated
Copy link
Copy Markdown
Contributor

@polymerizedsage polymerizedsage left a comment

Choose a reason for hiding this comment

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

Tested locally and this works for me. Some small comments but otherwise lgtm

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

And to be explicit, the reason why people want that ordering is because then you can easily do from the terminal:

synapsectl --uri <name> info

# up arrow, backspace
synapsectl --uri <name> start

rather than moving back and switching the command.

AFAIK you can still do

synapsectl <name> start

without --uri with your changes. The old code still included the option to have a flag its just not strictly necessary. I tested locally and it worked just fine. Maybe im missing something.

I can't reproduce this with the start command.

read did have an errant uri command. I'll look for others.

@gilbert-sci
Copy link
Copy Markdown
Contributor Author

@polymerizedsage but also I can't reproduce that with read, it just fails. So I'm not sure how you got that working

Copy link
Copy Markdown
Contributor

@antoniaelsen antoniaelsen left a comment

Choose a reason for hiding this comment

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

tested, lgtm

@gilbert-sci gilbert-sci merged commit 7eb7e42 into main Apr 17, 2025
2 checks passed
@gilbert-sci gilbert-sci deleted the gilbert/find-by-name branch April 17, 2025 19:13
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.

4 participants