Browse Source

improve device discovery output with found keyboard details

Paul Klumpp 2 tuần trước cách đây
mục cha
commit
d3e55e51d6
3 tập tin đã thay đổi với 29 bổ sung và 4 xóa
  1. 11 0
      AGENTS.md
  2. 10 3
      README.md
  3. 8 1
      internal/device/device.go

+ 11 - 0
AGENTS.md

@@ -104,6 +104,17 @@ prints JSON before returning non-zero.
 - Output should be machine-parseable (JSON when possible)
 - Cross-platform from day one
 
+## Consistency
+
+Names used in code must appear identically everywhere. Before any edit:
+
+1. **Binary name** — the `go build -o` target (usually `$GOBIN/$module_name`) must match every example in README, AGENTS.md, comments, and docs.
+2. **CLI command** — the root command name (e.g. `qmk-rgb`) is the binary name; every usage example, CLI reference table, and doc must use the same string.
+3. **Module path** — the `go.mod` module path is the source of truth for `go install` targets.
+4. **Zone names** — `logo`, `backlight`, `side` must be identical in code, docs, and examples.
+
+When you see a name in one file, grep for it across the whole repo before deciding if a change is consistent.
+
 ## Code vs Documentation
 
 All documentation (README.md, comments, AGENTS.md) must stay in sync with the code.

+ 10 - 3
README.md

@@ -6,14 +6,21 @@ Cross-platform CLI for Linux, macOS, and Windows. Designed for automation, scrip
 
 ## Installation
 
+On Linux, `libudev-dev` is required before building:
+
+```bash
+sudo apt install -y libudev-dev
+```
+
+Build locally:
+
 ```bash
 git clone <repo-url>
-cd impact-80
+cd qmk-rgb
 go build -o qmk-rgb ./cmd/qmk-rgb/
 ```
 
-On Linux, `libudev-dev` is required for building (the hid library uses it for device discovery).
-Or install globally:
+And, to run it from anywhere, install globally (run from the repo root, installs to `$GOPATH/bin/`):
 
 ```bash
 go install ./cmd/qmk-rgb/

+ 8 - 1
internal/device/device.go

@@ -87,6 +87,13 @@ func Discover(keyboards []Keyboard) ([]Device, error) {
 		}
 	}
 
-	fmt.Fprintf(os.Stderr, "Discovering keyboards...\n")
+	if len(found) > 0 {
+		fmt.Fprintf(os.Stderr, "Discovered %d keyboard(s):\n", len(found))
+		for _, d := range found {
+			fmt.Fprintf(os.Stderr, "  - %s (VID=0x%04x PID=0x%04x) %s\n", d.Name, d.VendorID, d.ProductID, d.Path)
+		}
+	} else {
+		fmt.Fprintln(os.Stderr, "No keyboards found.")
+	}
 	return found, nil
 }