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

Feature idea: --dump $URL #9

Closed
kseistrup opened this issue Jan 7, 2020 · 10 comments
Closed

Feature idea: --dump $URL #9

kseistrup opened this issue Jan 7, 2020 · 10 comments

Comments

@kseistrup
Copy link
Contributor

It would be sweet to be able to dump a rendered version of a gopher URL with e.g. -d URL/--dump URL, such that the output is coloured if stdout is a TTY and plain text if not. This feature complements the -r/--raw switch, similarly to what we can do with e.g. lynx and w3m:

$ lynx --dump "$URL"       # dump a formatted page to stdout
$ lynx --source "$URL"     # dump raw html to stdout
$ w3m -dump "$URL"         # dump a formatted page to stdout
$ w3m -dump_source "$URL"  # dump raw html to stdout
@xvxx
Copy link
Owner

xvxx commented Jan 7, 2020

This is great! What do you think about -p/--print? --dump to me implies some sort of programmer-y debug thing, but maybe compat with lynx is important in your mind?

I've added it to master but I think it needs two a few more tweaks:

  • Hide the cursor (the *) in "print mode".
  • Some way to launch in "wide" mode so there's no left margin.
  • Edit: Disable colors when not connected to TTY

I'll look into adding a way to launch in wide mode with -w, which would be cool for this and regular usage too.

image

@kseistrup
Copy link
Contributor Author

kseistrup commented Jan 7, 2020

That looks great!

I am not overly concerned about the name of the switch, I only chose --dump because it is already used in both w3m and lynx. If you like --print better, that's fine.

I never gave the cursor or the default display mode a thought before posting my suggestion, but now that I see it in my terminal, I think you're right about both: wide mode and no cursor. Otherwise well done!

@kseistrup
Copy link
Contributor Author

PS: And no colours if stdout is not a TTY:

$ phetch -p port70.dk | cat
fatal: Can't get terminal size. Please file a bug: https://github.com/dvkt/phetch/issues/new

(I know you have just started on this, it's just an illustration.)

@xvxx
Copy link
Owner

xvxx commented Jan 7, 2020

Ah perfect, thank you. Yes disabling colors is needed for this. I'll keep this issue open until those three improvements get ironed out.

@xvxx
Copy link
Owner

xvxx commented Jan 12, 2020

This should be fully operational now, give or take a few bugs. It will be in the next release.

image

The TTY-less version should also be working now:

$ ./phetch -p phkt.io | cat      
  ____    _   _     _  __    _____
U|  _"\ u|'| |'|   |"|/ /   |_ " _|
\| |_) |/| |_| |\  | ' /      | |
 |  __/ U|  _  |uU/| . \\u   /| |\
 |_|     |_| |_|   |_|\_\   u |_|U
 ||>>_   //   \\ ,-,>> \\,-._// \\_
(__)__) (_") ("_) \.)   (_/(__) (__)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       < xvxx's gopherhole >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

projects
> gopher, languages, etc.

links
> frequent stops

about
> about me and this server

Thank you for the suggestion! 🎆 🍾

@xvxx xvxx closed this as completed Jan 12, 2020
@kseistrup
Copy link
Contributor Author

That looks really nice. Thanks!! 👍

@xvxx
Copy link
Owner

xvxx commented Jan 12, 2020

One thing I just noticed:

phetch sdf.org | cat
Error: ....

This should probably default to the tty-less plain output, or at least show a nicer error.

@kseistrup
Copy link
Contributor Author

Perhaps I already have a binary that works? phetch sdf.org | cat looks fine here.

@xvxx
Copy link
Owner

xvxx commented Jan 13, 2020

Well, it turns out I already changed this in master before leaving my comment. Is it possible to sleepcode, like sleepwalk? Or maybe I've become unstuck in time like Billy Pilgrim...

@kseistrup
Copy link
Contributor Author

Sleepcode 😸

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

No branches or pull requests

2 participants