News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

[nettool] Configureable output format

Started by Michael 'Cruzer', November 12, 2014, 04:25:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Michael 'Cruzer'

At the moment nettool outputs it's results as human readable plain text. But for scripting it would be nice if nettool can export it's result as CSV, JSON or similar.
Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

prissi

nettool uses the same routines as in simutrans. Hence the same output. Or what do you refer too?

Michael 'Cruzer'

I'm referring to the console output. At the moment asking for online clients response looks like:

List of playing clients:
  [  2]  ..   77.119.232.50


or even more complicated to process is the response for online companies:

Company #0: S?o Cruzer VB
    Password: set
    played by Michael at 1.234.56.78
Company #1: ?ffentliche Hand
    Password: NOT set
    unlocked for [0] Server#0 at 0.0.0.0
    unlocked for [2] Michael at 1.234.56.78
    played by Michael at 1.234.56.78
    played by Citarofahrer at 1.234.56.78
    played by Ophiucchus at 1.234.56.78
Company #2: Flemmolistik
    Password: NOT set
    unlocked for [0] Server#0 at 0.0.0.0
    unlocked for [2] Michael at 1.234.56.82
    played by Nils at 1.234.56.81
    played by Nils at 1.234.56.80
    played by Nils at 1.234.56.79
    played by Nils at 1.234.56.78
    played by Ophiucchus at 1.234.56.78
Company #5: Greenrail Ltd.
    Password: set
    played by greenlamp35 at 1.234.56.78
Company #6: Citaro Transport
    Password: NOT set
    founded by Citarofahrer at 1.234.56.78
    unlocked for [0] Server#0 at 0.0.0.0
    unlocked for [2] Michael at 1.234.56.78
    played by Citarofahrer at 1.234.56.78
    played by Taurus at 1.234.56.78
Company #12: Fietogistics
    Password: set
    played by Ophiucchus at 1.234.56.79
    played by Ophiucchus at 1.234.56.78
    played by Ophiucchus at 1.234.56.77


To use that information in a script I need to apply a regular expression to fetch information from that plain text information. It would be great to have a switch like "--format CSV" or "--format JSON" which will format the response as the declared output format.
Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

prissi

Honestly, I suggest to make a small patch for it. If you can do regexp, doing the desired output in C++ is a piece of cake. Then I would not have to guess what you would like most.