~hedy/inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH gelim] Do not show error message on exit through CTRL-D

Details
Message ID
<20211023191545.7116-1-codesoap@mailbox.org>
DKIM signature
pass
Download raw message
Patch: +5 -1
---
First time using git send-email; hope this works... Thanks for writing
this gemini client, it's my favourite so far, after trying most of the
"mainstream" ones! I usually exit programs, that give me readlines with
CTRL-D. Before this patch, gelim would exit on CTRL-D, but also display
an error message.

 gelim.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gelim.go b/gelim.go
index 1953c30..3f6938c 100644
--- a/gelim.go
+++ b/gelim.go
@@ -151,7 +151,11 @@ func main() {
		}
		color.Unset()

		if err != nil {
		if err == io.EOF {
			// Exit by CTRL-D.
			fmt.Println("")
			c.QuitClient(0)
		} else if err != nil {
			if err != ln.ErrPromptAborted {
				c.style.ErrorMsg("error reading line input: " + err.Error())
			}
-- 
2.33.0
Details
Message ID
<6a1cfa4c81fbb9d546630128322593af@tilde.cafe>
In-Reply-To
<20211023191545.7116-1-codesoap@mailbox.org> (view parent)
DKIM signature
missing
Download raw message
(oops I didn't reply all, ignore the double email)

***

Hi! Sorry for the delay. Your patch sent successfully :)

I'm glad it's your favorite client. It's a pity that I haven't
been able to work on it for quite a long time due to IRL issues,
but I'm sure I'll find time for it real soon.

> @@ -151,7 +151,11 @@ func main() {
>  		 }
>  		 color.Unset()
> 
> -		 if err != nil {
> +		 if err == io.EOF {
> +			 // Exit by CTRL-D.
> +			 fmt.Println("")
> +			 c.QuitClient(0)
> +		 } else if err != nil {
>  			 if err != ln.ErrPromptAborted {
>  				 c.style.ErrorMsg("error reading line input: " + err.Error())
>  			 }

This looks good but it would be amazing if we could refactor it
to put checking for io.EOF together with checking for ln.ErrPromotAborted.
So line 154 would be untouched, and line 155 could be something like:

if err != ln.ErrPromptAborted && err != io.EOF {

I haven't tested it though, if you'd like to keep the fmt.Println
line you can put it right under `err != nil` so a new line is
printed regardless of the error.

Do you know how to send a v2? I hope you'll figure it out, good luck!
Details
Message ID
<20211124193444.64484-1-codesoap@mailbox.org>
In-Reply-To
<6a1cfa4c81fbb9d546630128322593af@tilde.cafe> (view parent)
DKIM signature
pass
Download raw message
Patch: +6 -1
---
Is this what you had in mind? I would still add an additional 'if' to
exit with exit code 0 on CTLR-D.

 gelim.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gelim.go b/gelim.go
index 1953c30..066a2ec 100644
--- a/gelim.go
+++ b/gelim.go
@@ -152,9 +152,14 @@ func main() {
		color.Unset()

		if err != nil {
			if err != ln.ErrPromptAborted {
			if err != ln.ErrPromptAborted && err != io.EOF {
				c.style.ErrorMsg("error reading line input: " + err.Error())
			}
			fmt.Println("")
			if err == io.EOF {
				// Exit by CTRL-D.
				c.QuitClient(0)
			}
			// Exiting because it will cause an infinite loop of error if used 'continue' here
			c.QuitClient(1)
		}
-- 
2.33.0
Details
Message ID
<CGUDXJ3K80EH.2RK1B7IOQ9D33@cafe>
In-Reply-To
<20211124193444.64484-1-codesoap@mailbox.org> (view parent)
DKIM signature
missing
Download raw message
Can be improved but I'll do it, thanks!
Reply to thread Export thread (mbox)