Skip to content

[feature] Add "--bind" argument to "sonar list"#26

Open
mct wants to merge 1 commit intoraskrebs:mainfrom
mct:mct/show-bind-address
Open

[feature] Add "--bind" argument to "sonar list"#26
mct wants to merge 1 commit intoraskrebs:mainfrom
mct:mct/show-bind-address

Conversation

@mct
Copy link
Copy Markdown

@mct mct commented Mar 24, 2026

What does this PR do?

Adds sonar list --bind argument, to easily display the IP address a port is bound to.

Searches the list of display columns for the word port and inserts the word bind immediately after it. This lets it work nicely when only --bind is passed, or when called with --stats --bind, or even with --columns port,name --bind

Related issue

None

How was this tested?

Tested on Linux and macOS with:

sonar list
sonar list --bind
sonar list --bind --stats
sonar list --columns port --bind
sonar list --columns pid,port --bind
sonar list --columns port,pid --bind
sonar list --columns port,name --bind
sonar list --columns pid --bind # bind address not displayed, because "port" not shown
sonar list --columns pid,process,type --bind # bind address not displayed, because "port" not shown

Checklist

  • I have tested this on my platform (macOS / Linux)
  • My changes don't break existing functionality
  • I have updated documentation if needed

Searches the list of display columns for the word "port" and inserts
the word "bind" immediately after it. This lets it work nicely when
only "--bind" is passed, or when called with "--stats --bind", or even
with "--columns port,name --bind"
@mct mct requested a review from raskrebs as a code owner March 24, 2026 00:20
@raskrebs
Copy link
Copy Markdown
Owner

Hi @mct,
You are aware that it's possible to show the up a port is bound to with the columns flag?

sonar list -c port,process,pid,type,url,bind
PORT   PROCESS                      PID     TYPE     URL                     BIND   
1780   proxy (traefik:3.0)          35029   docker   http://localhost:1780   0.0.0.0

I'm not against making it easier to add columns on top of the default ones, but then i think we should generalize this. If you think it's a very relevant flag to add and will make the tool more useful for you then i'm not against adding it.

And thanks a ton for your contribution, much appreciated!!

@mct
Copy link
Copy Markdown
Author

mct commented Mar 27, 2026

It's certainly possible without this feature to display the bound IP using sonar list -c port,bind,process,container,image,cport,url, but that's somewhat impractical to type each time :-) And because list is a second-level command under sonar, it's difficult to e.g. create a bash alias for it, the way one can with, say, alias ls="ls -AF"

Perhaps this could be generalized by having sonar look for an environment variable SONAR_LIST_COLUMNS to contain the default list of columns, if -c is not specified?

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.

2 participants