The International Simutrans Forum

 

Author Topic: [nettool] Configureable output format  (Read 1367 times)

0 Members and 1 Guest are viewing this topic.

Offline Michael 'Cruzer'

  • Devotee
  • *
  • Posts: 196
  • Founder of pak192.comic
    • Marktplatz für Parkplätze
  • Languages: DE, EN
[nettool] Configureable output format
« on: November 12, 2014, 04:25:59 PM »
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9565
  • Languages: De,EN,JP
Re: [nettool] Configureable output format
« Reply #1 on: November 13, 2014, 04:03:26 PM »
nettool uses the same routines as in simutrans. Hence the same output. Or what do you refer too?

Offline Michael 'Cruzer'

  • Devotee
  • *
  • Posts: 196
  • Founder of pak192.comic
    • Marktplatz für Parkplätze
  • Languages: DE, EN
Re: [nettool] Configureable output format
« Reply #2 on: November 16, 2014, 09:23:49 AM »
I'm referring to the console output. At the moment asking for online clients response looks like:

 
Code: [Select]
List of playing clients:
  [  2]  ..   77.119.232.50

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

Code: [Select]
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9565
  • Languages: De,EN,JP
Re: [nettool] Configureable output format
« Reply #3 on: November 16, 2014, 09:16:05 PM »
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.