rnwood / smtp4dev

smtp4dev - the fake smtp email server for development and testing
BSD 3-Clause "New" or "Revised" License
3.1k stars 346 forks source link

How to display version? #928

Closed eanon closed 3 years ago

eanon commented 3 years ago

How to display (or check programmatically) the smtp4dev version? Unless mistake, I don't see this indication in the client UI nor through a command line option like the usual "--version". TIA

eanon commented 3 years ago

OK, using the "--help" option on cmdline, it displays the version at top of the help... But how when smtp4dev is running as a service?

To develop a little: I have several dev and staging platforms, and I would like to know the ones to update or not... Some are running smtp4dev as a service under Windows and some others as a daemon under Linux (ie. systemd); or in docker. Is there a way to check the smtp4dev version programmatically or see it through the web client (so I could scrape it)?

-- EDIT: for now, I just catch the output of "Rnwood.smpt4dev --help" (or going through "docker exec -t -i /app/Rnwood.Smtp4dev --help" when smpt4dev is in a docker container), then parse it. So, if a "--version" option returning the version only would exist, I think it would be a plus, but I can live like this :)

jafin commented 3 years ago

If there was an http api endpoint to hit would that suit? ie HTTP get to /config/version returns 3.1.0 for example You could then scrape all the instances with curl or similar quite easily?

eanon commented 3 years ago

Yes, it would be perfect!

Awaiting, I extract the version string from command line using something like this (in my test-suite in Python):

cmd = "docker exec d9b68a69a7e7 /app/Rnwood.Smtp4dev --help | grep 'smtp4dev version'"
proc = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
output_parts = proc.stdout.split()
curr_ver_str = output_parts[len(output_parts) - 1]