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 ( | |
| 17 | 17 | "github.com/picosh/pico/pkg/shared" | |
| 18 | 18 | ) | |
| 19 | 19 | ||
| 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 | + | ||
| 20 | 31 | func StartSshServer() { | |
| 21 | 32 | appName := "pastes-ssh" | |
| 22 | 33 |
| ... | ... | @@ -52,7 +63,7 @@ func StartSshServer() { | |
| 52 | 63 | scp.Middleware(handler), | |
| 53 | 64 | rsync.Middleware(handler), | |
| 54 | 65 | auth.Middleware(handler), | |
| 55 | - | pssh.PtyMdw(pssh.DeprecatedNotice()), | |
| 66 | + | pssh.PtyMdw(pssh.HelpNotice(help)), | |
| 56 | 67 | pssh.LogMiddleware(handler, dbh), | |
| 57 | 68 | }, | |
| 58 | 69 | []pssh.SSHServerMiddleware{ |
+10,
-1
| ... | ... | @@ -18,6 +18,15 @@ import ( | |
| 18 | 18 | "github.com/picosh/pico/pkg/storage" | |
| 19 | 19 | ) | |
| 20 | 20 | ||
| 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 | + | ||
| 21 | 30 | func StartSshServer() { | |
| 22 | 31 | appName := "prose-ssh" | |
| 23 | 32 |
| ... | ... | @@ -62,7 +71,7 @@ func StartSshServer() { | |
| 62 | 71 | scp.Middleware(handler), | |
| 63 | 72 | rsync.Middleware(handler), | |
| 64 | 73 | auth.Middleware(handler), | |
| 65 | - | pssh.PtyMdw(pssh.DeprecatedNotice()), | |
| 74 | + | pssh.PtyMdw(pssh.HelpNotice(help)), | |
| 66 | 75 | pssh.LogMiddleware(handler, dbh), | |
| 67 | 76 | }, | |
| 68 | 77 | []pssh.SSHServerMiddleware{ |
+4,
-8
| ... | ... | @@ -2,22 +2,18 @@ package pssh | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "encoding/binary" | |
| 5 | - | "fmt" | |
| 5 | + | "strings" | |
| 6 | 6 | ) | |
| 7 | 7 | ||
| 8 | 8 | func SessionMessage(sesh *SSHServerConnSession, msg string) { | |
| 9 | 9 | _, _ = sesh.Write([]byte(msg + "\r\n")) | |
| 10 | 10 | } | |
| 11 | 11 | ||
| 12 | - | func DeprecatedNotice() SSHServerMiddleware { | |
| 12 | + | // HelpNotice writes help to the session, translating newlines for the client's pty. | |
| 13 | + | func HelpNotice(help string) SSHServerMiddleware { | |
| 13 | 14 | return func(next SSHServerHandler) SSHServerHandler { | |
| 14 | 15 | 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")) | |
| 21 | 17 | return next(sesh) | |
| 22 | 18 | } | |
| 23 | 19 | } |