Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

results output suggestion #4

Open
gilcot opened this issue Apr 12, 2017 · 5 comments
Open

results output suggestion #4

gilcot opened this issue Apr 12, 2017 · 5 comments

Comments

@gilcot
Copy link

gilcot commented Apr 12, 2017

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
Copy link
Owner

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
Copy link
Author

gilcot commented May 23, 2017

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
Copy link
Owner

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
Copy link
Owner

thoughts?

@gilcot
Copy link
Author

gilcot commented May 27, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants