diff --git a/modules/scan/README.md b/modules/brother/README.md similarity index 94% rename from modules/scan/README.md rename to modules/brother/README.md index 0b339f15..44733dba 100644 --- a/modules/scan/README.md +++ b/modules/brother/README.md @@ -1,4 +1,4 @@ -# scan — scan a document, crop it, file it, say so +# brother — scan a document, crop it, file it, say so Built for issue 1440 as novox/hq ADR 0464 decides. It scans the glass of a network scanner (any scanner that speaks eSCL, also called AirScan or Mopria), cuts the document out of the lid's white, files it as a one-page PDF @@ -47,7 +47,7 @@ makes it (mode 0755) when it files the first scan. ## The event -`scan.added`, on the wire `mesh.mod.scan.event.scan.added`; a consumer declares `scan.scan.added`. Its body: +`scan.added`, on the wire `mesh.mod.brother.event.scan.added`; a consumer declares `brother.scan.added`. Its body: `path`, `node`, `bytes`, `sha256`, `width-mm`, `height-mm`, `resolution` (dpi, as the scanner gave it), `color-mode`, `cropped`, `scanned-at` (RFC 3339, UTC). @@ -62,5 +62,5 @@ Each directory or archive this module declares says how it treats a file it did ## Tests -The unit tests use the captured answers of a real scanner (`cmd/scan/testdata/escl`, captured 2026-10-20) served +The unit tests use the captured answers of a real scanner (`cmd/brother/testdata/escl`, captured 2026-10-20) served by a test HTTP server; no test reaches a scanner. diff --git a/modules/scan/cmd/scan/crop.go b/modules/brother/cmd/brother/crop.go similarity index 100% rename from modules/scan/cmd/scan/crop.go rename to modules/brother/cmd/brother/crop.go diff --git a/modules/scan/cmd/scan/crop_test.go b/modules/brother/cmd/brother/crop_test.go similarity index 100% rename from modules/scan/cmd/scan/crop_test.go rename to modules/brother/cmd/brother/crop_test.go diff --git a/modules/scan/cmd/scan/escl.go b/modules/brother/cmd/brother/escl.go similarity index 100% rename from modules/scan/cmd/scan/escl.go rename to modules/brother/cmd/brother/escl.go diff --git a/modules/scan/cmd/scan/escl_test.go b/modules/brother/cmd/brother/escl_test.go similarity index 100% rename from modules/scan/cmd/scan/escl_test.go rename to modules/brother/cmd/brother/escl_test.go diff --git a/modules/scan/cmd/scan/file.go b/modules/brother/cmd/brother/file.go similarity index 100% rename from modules/scan/cmd/scan/file.go rename to modules/brother/cmd/brother/file.go diff --git a/modules/scan/cmd/scan/file_test.go b/modules/brother/cmd/brother/file_test.go similarity index 100% rename from modules/scan/cmd/scan/file_test.go rename to modules/brother/cmd/brother/file_test.go diff --git a/modules/scan/cmd/scan/helpers_test.go b/modules/brother/cmd/brother/helpers_test.go similarity index 100% rename from modules/scan/cmd/scan/helpers_test.go rename to modules/brother/cmd/brother/helpers_test.go diff --git a/modules/scan/cmd/scan/main.go b/modules/brother/cmd/brother/main.go similarity index 96% rename from modules/scan/cmd/scan/main.go rename to modules/brother/cmd/brother/main.go index de13cfa4..9d699f48 100644 --- a/modules/scan/cmd/scan/main.go +++ b/modules/brother/cmd/brother/main.go @@ -10,7 +10,7 @@ import ( ) func main() { - if err := stdio.Serve("", tools(os.Getenv("SCAN_SETTINGS"), emit, time.Now)); err != nil { + if err := stdio.Serve("", tools(os.Getenv("BROTHER_SETTINGS"), emit, time.Now)); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } diff --git a/modules/scan/cmd/scan/manifest_test.go b/modules/brother/cmd/brother/manifest_test.go similarity index 97% rename from modules/scan/cmd/scan/manifest_test.go rename to modules/brother/cmd/brother/manifest_test.go index c250e66d..86c60a74 100644 --- a/modules/scan/cmd/scan/manifest_test.go +++ b/modules/brother/cmd/brother/manifest_test.go @@ -86,11 +86,11 @@ func TestTheConfigReachesTheCodeThroughItsSettingsFile(t *testing.T) { env := "" for _, a := range m.Build.Artifacts { if a["kind"] == "bundle" { - env, _ = a["env"].(map[string]any)["SCAN_SETTINGS"].(string) + env, _ = a["env"].(map[string]any)["BROTHER_SETTINGS"].(string) } } if env != "${dir:state}/settings.json" { - t.Errorf("SCAN_SETTINGS = %q", env) + t.Errorf("BROTHER_SETTINGS = %q", env) } raw, err := os.ReadFile(filepath.Join("..", "..", "files", "settings.json")) if err != nil { diff --git a/modules/scan/cmd/scan/pdf.go b/modules/brother/cmd/brother/pdf.go similarity index 100% rename from modules/scan/cmd/scan/pdf.go rename to modules/brother/cmd/brother/pdf.go diff --git a/modules/scan/cmd/scan/scan.go b/modules/brother/cmd/brother/scan.go similarity index 95% rename from modules/scan/cmd/scan/scan.go rename to modules/brother/cmd/brother/scan.go index 87c9002a..d625fa03 100644 --- a/modules/scan/cmd/scan/scan.go +++ b/modules/brother/cmd/brother/scan.go @@ -9,8 +9,8 @@ import ( "time" ) -// EventAdded is the module's event: a scan was filed (ADR 0464). Consumers declare scan.scan.added; it -// travels as mesh.mod.scan.event.scan.added. It names the file and never carries the image. +// EventAdded is the module's event: a scan was filed (ADR 0464). Consumers declare brother.scan.added; it +// travels as mesh.mod.brother.event.scan.added. It names the file and never carries the image. const EventAdded = "scan.added" // Emitter says an event on the bus under a message id, so a repeated publish is kept to one (ADR 0436). diff --git a/modules/scan/cmd/scan/service_test.go b/modules/brother/cmd/brother/service_test.go similarity index 100% rename from modules/scan/cmd/scan/service_test.go rename to modules/brother/cmd/brother/service_test.go diff --git a/modules/scan/cmd/scan/settings.go b/modules/brother/cmd/brother/settings.go similarity index 84% rename from modules/scan/cmd/scan/settings.go rename to modules/brother/cmd/brother/settings.go index 3f6ddb8d..b15175e3 100644 --- a/modules/scan/cmd/scan/settings.go +++ b/modules/brother/cmd/brother/settings.go @@ -1,4 +1,4 @@ -// Package main is the scan module's Go tools bundle (novox/hq ADR 0464, issue 1440): it scans the glass of a +// Package main is the brother module's Go tools bundle (novox/hq ADR 0464, issue 1440): it scans the glass of a // network scanner over eSCL, crops the document, files it as a one-page PDF in a folder and says so on the bus. // A scan happens when a tool is called; the module runs no process of its own. package main @@ -25,12 +25,12 @@ type Settings struct { Crop bool } -// LoadSettings reads settings.json (the file named by SCAN_SETTINGS) and lays the defaults under it. A missing +// LoadSettings reads settings.json (the file named by BROTHER_SETTINGS) and lays the defaults under it. A missing // or unreadable file is an error that names it; an unset scanner or folder is Missing's to say. func LoadSettings(path string) (Settings, error) { s := Settings{Resolution: 300, ColorMode: "color", Crop: true} if path == "" { - return s, fmt.Errorf("SCAN_SETTINGS names no settings file: the module's config does not reach the code") + return s, fmt.Errorf("BROTHER_SETTINGS names no settings file: the module's config does not reach the code") } raw, err := os.ReadFile(path) if err != nil { @@ -71,6 +71,6 @@ func (s Settings) Missing() error { if len(unset) == 0 { return nil } - return fmt.Errorf("config value %s is not set: the operator gives it with the config verb for the scan module on this node", + return fmt.Errorf("config value %s is not set: the operator gives it with the config verb for the brother module on this node", strings.Join(unset, " and ")) } diff --git a/modules/scan/cmd/scan/testdata/escl/capabilities.xml b/modules/brother/cmd/brother/testdata/escl/capabilities.xml similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/capabilities.xml rename to modules/brother/cmd/brother/testdata/escl/capabilities.xml diff --git a/modules/scan/cmd/scan/testdata/escl/doc-headers.txt b/modules/brother/cmd/brother/testdata/escl/doc-headers.txt similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/doc-headers.txt rename to modules/brother/cmd/brother/testdata/escl/doc-headers.txt diff --git a/modules/scan/cmd/scan/testdata/escl/post-headers.txt b/modules/brother/cmd/brother/testdata/escl/post-headers.txt similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/post-headers.txt rename to modules/brother/cmd/brother/testdata/escl/post-headers.txt diff --git a/modules/scan/cmd/scan/testdata/escl/scan.jpg b/modules/brother/cmd/brother/testdata/escl/scan.jpg similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/scan.jpg rename to modules/brother/cmd/brother/testdata/escl/scan.jpg diff --git a/modules/scan/cmd/scan/testdata/escl/settings.xml b/modules/brother/cmd/brother/testdata/escl/settings.xml similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/settings.xml rename to modules/brother/cmd/brother/testdata/escl/settings.xml diff --git a/modules/scan/cmd/scan/testdata/escl/status-after.xml b/modules/brother/cmd/brother/testdata/escl/status-after.xml similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/status-after.xml rename to modules/brother/cmd/brother/testdata/escl/status-after.xml diff --git a/modules/scan/cmd/scan/testdata/escl/status-idle.xml b/modules/brother/cmd/brother/testdata/escl/status-idle.xml similarity index 100% rename from modules/scan/cmd/scan/testdata/escl/status-idle.xml rename to modules/brother/cmd/brother/testdata/escl/status-idle.xml diff --git a/modules/brother/cmd/brother/testdata/ipp/get-printer-attributes.answer b/modules/brother/cmd/brother/testdata/ipp/get-printer-attributes.answer new file mode 100644 index 00000000..2ec08548 Binary files /dev/null and b/modules/brother/cmd/brother/testdata/ipp/get-printer-attributes.answer differ diff --git a/modules/brother/cmd/brother/testdata/ipp/get-printer-attributes.request b/modules/brother/cmd/brother/testdata/ipp/get-printer-attributes.request new file mode 100644 index 00000000..f33e31f9 Binary files /dev/null and b/modules/brother/cmd/brother/testdata/ipp/get-printer-attributes.request differ diff --git a/modules/scan/files/settings.json b/modules/brother/files/settings.json similarity index 100% rename from modules/scan/files/settings.json rename to modules/brother/files/settings.json diff --git a/modules/scan/go.mod b/modules/brother/go.mod similarity index 85% rename from modules/scan/go.mod rename to modules/brother/go.mod index 8affa504..18d9b8c4 100644 --- a/modules/scan/go.mod +++ b/modules/brother/go.mod @@ -1,4 +1,4 @@ -module scan +module brother go 1.26.0 diff --git a/modules/scan/go.sum b/modules/brother/go.sum similarity index 100% rename from modules/scan/go.sum rename to modules/brother/go.sum diff --git a/modules/scan/module.json b/modules/brother/module.json similarity index 93% rename from modules/scan/module.json rename to modules/brother/module.json index e5f3bba5..ce4c1a00 100644 --- a/modules/scan/module.json +++ b/modules/brother/module.json @@ -1,5 +1,5 @@ { - "module": "scan", + "module": "brother", "version": "1", "emits": [ "scan.added" @@ -83,13 +83,13 @@ "kind": "bundle", "language": "go", "system": "arch", - "from": "cmd/scan", - "binary": "scan", + "from": "cmd/brother", + "binary": "brother", "loads": [ - "scan" + "brother" ], "env": { - "SCAN_SETTINGS": "${dir:state}/settings.json" + "BROTHER_SETTINGS": "${dir:state}/settings.json" } }, {