alextremblay / phpIPAM-Scraper

A python library to retrieve device IPs from a phpIPAM installation
1 stars 0 forks source link

results output suggestion #4

Open gilcot opened 7 years ago

gilcot commented 7 years ago

Hello,

While in phpipam shell like, It's better to display the get command results via the system pager... (see similare discussion with use of Popen or pydoc with fallback to print etc.) It's usefull when there are many results (often 2 or 3 pages) but also for people that don't want folding. For system page, it's better to use the environment variable $PAGER (some one may set it vi, some other to less -S, some may prefer pg -f or just more -f witch is always the-facto fallback when the environnement variable is empty

While using a direct call, e.g.phpipam -u <user> -p <pass> get all <keyword>, It's better not have column aligned outputs but fields separed by tabulation (or another separator if defined in configuration file) This makes it easy to pipe to filters like cut and so.

Thanks.

alextremblay commented 7 years ago

I like this idea a lot.

I'm not sure how I'd implement this in a portable cross-platform way (or if it's even possible), but the idea intruiges me.

Let me mull it over for a bit.

gilcot commented 7 years ago

Hello,

Thanks for the input.
There're two ideas here (maybe I should have opend different issues? but the're all related to output displaying)

  1. output though system pager (and I don't know how this one can be portable, I have to admit that I didn't think about it)
  2. une tabulation as delimiter instead of columns positions (and I think that all operating systems know how to handle tab-character in their console)

Regards.

alextremblay commented 7 years ago

Hello again,

What I think I'm going to do for the display of data is to have my program check:

If it sees that it's being output to a tty like stdout, output stays as-is. If it detects that its output is being piped to something else, it will output data in csv format instead of formatting it as an ascii table.

alextremblay commented 7 years ago

thoughts?

gilcot commented 7 years ago

Hello,

You made a very good suggestion: people do like having nice formating (like now) and often have a wider screen/terminal (mine is sixty columns, what make some long lines mess.) It's a good agreement if you that's possible (I didn't know it's possible to detect if the output is being piped or being redirected)

Thanks.