Commit 759b2ff

Antonio Mika  ·  2026-10-22 10:46:37 -0400 EDT
parent 5f72092
feat(pastes,prose): print help instead of the deprecation notice
3 files changed,  +26, -10
+12, -1
......@@ -17,6 +17,17 @@ import (
1717 "github.com/picosh/pico/pkg/shared"
1818 )
1919
20+const help = `pastes.sh: upload plain text snippets over ssh
21+
22+ echo "foobar" | ssh pastes.sh upload with a random name
23+ echo "foobar" | ssh pastes.sh FILENAME upload as FILENAME
24+ echo "foobar" | ssh pastes.sh FILENAME expires=1h expire after a duration, on a date, or never (false); default 90 days
25+ echo "foobar" | ssh pastes.sh FILENAME hidden=true leave it off your pastes page
26+ rsync FILE pastes.sh:/ scp and sftp work too
27+
28+Run ssh pico.sh for your dashboard. Docs: https://pico.sh/pastes
29+`
30+
2031 func StartSshServer() {
2132 appName := "pastes-ssh"
2233
......@@ -52,7 +63,7 @@ func StartSshServer() {
5263 scp.Middleware(handler),
5364 rsync.Middleware(handler),
5465 auth.Middleware(handler),
55- pssh.PtyMdw(pssh.DeprecatedNotice()),
66+ pssh.PtyMdw(pssh.HelpNotice(help)),
5667 pssh.LogMiddleware(handler, dbh),
5768 },
5869 []pssh.SSHServerMiddleware{
+10, -1
......@@ -18,6 +18,15 @@ import (
1818 "github.com/picosh/pico/pkg/storage"
1919 )
2020
21+const help = `prose.sh: a blog you publish over ssh
22+
23+ rsync ~/blog/* prose.sh:/ publish posts and images; scp, sftp and sshfs work too
24+ cat post.md | ssh prose.sh hello-world.md upload one post
25+ cat post.md | ssh prose.sh upload with a random name
26+
27+Run ssh pico.sh for your dashboard. Docs: https://pico.sh/prose
28+`
29+
2130 func StartSshServer() {
2231 appName := "prose-ssh"
2332
......@@ -62,7 +71,7 @@ func StartSshServer() {
6271 scp.Middleware(handler),
6372 rsync.Middleware(handler),
6473 auth.Middleware(handler),
65- pssh.PtyMdw(pssh.DeprecatedNotice()),
74+ pssh.PtyMdw(pssh.HelpNotice(help)),
6675 pssh.LogMiddleware(handler, dbh),
6776 },
6877 []pssh.SSHServerMiddleware{
+4, -8
......@@ -2,22 +2,18 @@ package pssh
22
33 import (
44 "encoding/binary"
5- "fmt"
5+ "strings"
66 )
77
88 func SessionMessage(sesh *SSHServerConnSession, msg string) {
99 _, _ = sesh.Write([]byte(msg + "\r\n"))
1010 }
1111
12-func DeprecatedNotice() SSHServerMiddleware {
12+// HelpNotice writes help to the session, translating newlines for the client's pty.
13+func HelpNotice(help string) SSHServerMiddleware {
1314 return func(next SSHServerHandler) SSHServerHandler {
1415 return func(sesh *SSHServerConnSession) error {
15- msg := fmt.Sprintf(
16- "%s\r\n\r\nRun %s to access pico's TUI",
17- "DEPRECATED",
18- "ssh pico.sh",
19- )
20- SessionMessage(sesh, msg)
16+ SessionMessage(sesh, strings.ReplaceAll(strings.TrimRight(help, "\n"), "\n", "\r\n"))
2117 return next(sesh)
2218 }
2319 }