xonecas.io
8356
Wx

www-xonecas-io / commit 68b097e

site help shows every command and how to push a new repo (1042)

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 68b097e52e3050c599dfed2a1eb72306a4758784 parent b6fd48b

4 files changed

cmd/site/help.go+48−0
@@ -0,0 +1,48 @@
1+package main
2+
3+import (
4+ "flag"
5+ "fmt"
6+ "io"
7+)
8+
9+// usage is what site help prints. Run site from the site folder, where sources.txt is.
10+const usage = `site builds xonecas.io from git repos. Run it in the site folder.
11+
12+Repos
13+ site remote list list the repos the site shows
14+ site remote new <name> make a repo here that you git push to over SSH
15+ site remote add <path or url> show a repo you already have: a local path or any https URL
16+ site remote rm <path or url> stop showing a repo (a pushed repo's data is kept)
17+
18+Site
19+ site import fetch every added remote again
20+ site index read the repos into data/projects.json
21+ site build render public/
22+ site serve serve public/ on :8080
23+
24+ site <command> -h a command's flags
25+
26+Start a repo and push to it
27+ bin/site remote new my-thing prints the git remote add line for this machine
28+ cd ~/code/my-thing on any machine that can ssh here
29+ git remote add origin sacenox@vm:/home/sacenox/repos/www-xonecas-io/repos/xonecas.io/my-thing.git
30+ git push -u origin main each push rebuilds public/; the log is in my-thing.git/build.log
31+
32+Show a repo you already have
33+ bin/site remote add ~/code/other-thing
34+ bin/site index && bin/site build
35+
36+See the site
37+ make serve then open http://vm:8080
38+`
39+
40+// printUsage writes the usage, then fs's flags when there is a command.
41+func printUsage(w io.Writer, fs *flag.FlagSet) {
42+ fmt.Fprint(w, usage)
43+ if fs != nil {
44+ fmt.Fprintf(w, "\nFlags of site %s\n", fs.Name())
45+ fs.SetOutput(w)
46+ fs.PrintDefaults()
47+ }
48+}
cmd/site/main.go+5−2
@@ -24,11 +24,14 @@ import (
2424
2525 func main() {
2626 if len(os.Args) < 2 {
27- fmt.Fprintln(os.Stderr, "usage: site import|remote|index|build|serve [flags]")
27+ printUsage(os.Stderr, nil)
2828 os.Exit(2)
2929 }
3030 fs := flag.NewFlagSet(os.Args[1], flag.ExitOnError)
31+ fs.Usage = func() { printUsage(os.Stderr, fs) }
3132 switch os.Args[1] {
33+ case "help", "-h", "--help":
34+ printUsage(os.Stdout, nil)
3235 case "import":
3336 sources := fs.String("sources", "sources.txt", "clone URLs, one per line")
3437 root := fs.String("store", "repos", "folder for the bare mirrors")
@@ -84,7 +87,7 @@ func main() {
8487 log.Printf("serving %s on %s", *dir, *addr)
8588 log.Fatal(http.ListenAndServe(*addr, devnotes(*dir, http.FileServer(http.Dir(*dir)))))
8689 default:
87- fmt.Fprintln(os.Stderr, "usage: site import|remote|index|build|serve [flags]")
90+ printUsage(os.Stderr, nil)
8891 os.Exit(2)
8992 }
9093 }
cmd/site/remote.go+1−1
@@ -29,7 +29,7 @@ func remote(args []string, sources, root, meta string) error {
2929 return nil
3030 }
3131 if len(args) != 2 || !slices.Contains([]string{"add", "rm", "new"}, args[0]) {
32- return errors.New("usage: site remote list | new <name> | add <url or path> | rm <url or path>")
32+ return errors.New("usage: site remote list | new <name> | add <path or url> | rm <path or url>; site help shows more")
3333 }
3434 if args[0] == "new" {
3535 return newRepo(args[1], urls, sources, root, meta)
tickets/1042-how-do-we-add-new-remotes.md+16−2
@@ -5,9 +5,9 @@ type: feature
55 status: review
66 priority: p2
77 created: 2026-11-08T06:26:18Z
8-updated: 2026-11-08T07:08:43Z
8+updated: 2026-11-08T15:09:16Z
99 source: human
10-moves: 2026-11-08T06:26:22Z inbox doing drag; 2026-11-08T06:27:05Z doing review agent; 2026-11-08T06:57:08Z review doing drag; 2026-11-08T07:00:33Z doing review agent; 2026-11-08T07:01:42Z review todo note; 2026-11-08T07:01:44Z todo doing drag; 2026-11-08T07:04:04Z doing review agent
10+moves: 2026-11-08T06:26:22Z inbox doing drag; 2026-11-08T06:27:05Z doing review agent; 2026-11-08T06:57:08Z review doing drag; 2026-11-08T07:00:33Z doing review agent; 2026-11-08T07:01:42Z review todo note; 2026-11-08T07:01:44Z todo doing drag; 2026-11-08T07:04:04Z doing review agent; 2026-11-08T15:04:59Z review todo note; 2026-11-08T15:05:05Z todo doing drag; 2026-11-08T15:09:16Z doing review agent
1111 area: import
1212 ---
1313
@@ -67,3 +67,17 @@ Can we make this more formal, like a cli with the server bin? We could build on
6767 Not checked: the push over real SSH. Adding a test key to ~/.ssh/authorized_keys was blocked, so I pushed by path, which runs the same receive-pack and hook. Over SSH, only the transport differs.
6868 Important: repos/ is git-ignored, and this VM gets recreated. A hosted repo on the VM lives only there, so it would be lost on reset. Run new on the machine that serves xonecas.io, and back up repos/xonecas.io/.
6969 1043 (mirror path in published .git/config) also applies to hosted repos.
70+
71+- 2026-11-08 15:04Z (human): How do I use it? Am I suppoed to guess? What a incomtepentence fest.
72+
73+- 2026-11-08 15:09Z (agent): bin/site help now explains itself. Run make site, then bin/site help (or just bin/site). It shows every command, what it does, and two worked examples:
74+
75+ push a new repo: bin/site remote new my-thing
76+ git remote add origin sacenox@vm:/home/sacenox/repos/www-xonecas-io/repos/xonecas.io/my-thing.git
77+ git push -u origin main (each push rebuilds public/)
78+ show a repo: bin/site remote add ~/code/other-thing && bin/site index && bin/site build
79+ see it: make serve, open http://vm:8080
80+
81+ bin/site <command> -h adds that command's flags. Code: cmd/site/help.go, called from main.go.
82+ Checked from scratch in a temp site folder: remote new, two pushes, the hook rebuilt public/, the home page lists my-thing, /projects/my-thing/ returns 200, and git clone over HTTP from the served site gives both commits. go vet and go test pass. Temp files removed.
83+ Not checked: a push over real SSH from your host (I can't add a key here). Still true: this VM is recreated, so a repo made with remote new here is lost on reset.