Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71b4dda990 | ||
|
|
3d286da90d |
No files matched your search
@@ -1,9 +1,15 @@
|
|||||||
Copyright (c) 2026 yetano. All rights reserved.
|
Copyright (c) 2026 Bjoern Kalkbrenner. All rights reserved.
|
||||||
|
|
||||||
core is proprietary software. No license is granted to use, copy,
|
This software and its documentation are proprietary
|
||||||
modify, merge, publish, distribute, sublicense or sell copies of it, in
|
(SPDX: LicenseRef-Proprietary). No license to use, copy, modify, merge,
|
||||||
whole or in part, except with the prior written permission of the
|
publish, distribute, sublicense or sell copies of this software, in whole
|
||||||
|
or in part, is granted without the prior written permission of the
|
||||||
copyright holder.
|
copyright holder.
|
||||||
|
|
||||||
The Yetano projects are closed source for now; until their license is
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
decided, this notice applies.
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
@@ -328,7 +328,11 @@ docs/program-conventions.md in the meta-repository):
|
|||||||
- `doctor.Report` collects the locations the program resolves
|
- `doctor.Report` collects the locations the program resolves
|
||||||
(`AddPaths(app)` adds the standard `core/paths` ones) and named checks;
|
(`AddPaths(app)` adds the standard `core/paths` ones) and named checks;
|
||||||
`Run(args, stdout, stderr)` prints a table or `--json` and returns the
|
`Run(args, stdout, stderr)` prints a table or `--json` and returns the
|
||||||
exit code (0 all good, 1 a check failed, 2 usage).
|
exit code (0 all good, 1 a check failed, 2 usage). A check may carry
|
||||||
|
an `area` (a group such as "config" or "services") and a `hint` (what
|
||||||
|
to do about it), recorded with `Add(doctor.Check{...})`; both are
|
||||||
|
omitted from the JSON when empty, and the table only gets an AREA or
|
||||||
|
HINT column when some check uses it (since v0.10.0).
|
||||||
|
|
||||||
## core/configcmd: "<program> config"
|
## core/configcmd: "<program> config"
|
||||||
|
|
||||||
@@ -500,3 +504,7 @@ pitfalls and the yet-gui migration: [gui/README.md](gui/README.md).
|
|||||||
`slate`/`dialog`/`midnight` and their lipgloss styles, `Paint`/`Outer`,
|
`slate`/`dialog`/`midnight` and their lipgloss styles, `Paint`/`Outer`,
|
||||||
`ListState` and text helpers. No app shell or screens yet -- see
|
`ListState` and text helpers. No app shell or screens yet -- see
|
||||||
[tui/README.md](tui/README.md), which also has the migration steps.
|
[tui/README.md](tui/README.md), which also has the migration steps.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Proprietary (`LicenseRef-Proprietary`), see [LICENSE](LICENSE).
|
||||||
@@ -36,6 +36,8 @@ speculatively.
|
|||||||
whose fields are alternatives (SecretRef `env`/`file`/`value`);
|
whose fields are alternatives (SecretRef `env`/`file`/`value`);
|
||||||
`completion.Files` completes paths for programs without subcommands
|
`completion.Files` completes paths for programs without subcommands
|
||||||
(yamc) -- 2026-10-31.
|
(yamc) -- 2026-10-31.
|
||||||
|
- [x] `doctor.Check` with optional `area` and `hint` (JSON and table,
|
||||||
|
omitted when empty), `Report.Add` -- 2026-11-01, for v0.10.0.
|
||||||
- [x] macOS CLI/Service system-scope `RuntimeDir` is `/var/run/<app>`
|
- [x] macOS CLI/Service system-scope `RuntimeDir` is `/var/run/<app>`
|
||||||
(was `/run/<app>`, which macOS does not have) -- v0.5.0.
|
(was `/run/<app>`, which macOS does not have) -- v0.5.0.
|
||||||
- [x] `core/gui`: the native WebView host from
|
- [x] `core/gui`: the native WebView host from
|
||||||
|
|||||||
+31
-3
@@ -36,11 +36,16 @@ type Path struct {
|
|||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check is one named check.
|
// Check is one named check. Area (a group such as "config" or
|
||||||
|
// "services") and Hint (what to do about a failed check) are optional
|
||||||
|
// and omitted from the JSON form when empty, so a report without them
|
||||||
|
// looks exactly as before they existed.
|
||||||
type Check struct {
|
type Check struct {
|
||||||
|
Area string `json:"area,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
OK bool `json:"ok"`
|
OK bool `json:"ok"`
|
||||||
Note string `json:"note,omitempty"`
|
Note string `json:"note,omitempty"`
|
||||||
|
Hint string `json:"hint,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report is "<program> doctor --json"'s output.
|
// Report is "<program> doctor --json"'s output.
|
||||||
@@ -110,6 +115,12 @@ func (r *Report) Check(name string, ok bool, note string) {
|
|||||||
r.Checks = append(r.Checks, Check{Name: name, OK: ok, Note: note})
|
r.Checks = append(r.Checks, Check{Name: name, OK: ok, Note: note})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add records a check with all its fields, for a program that groups its
|
||||||
|
// checks into areas or gives hints.
|
||||||
|
func (r *Report) Add(c Check) {
|
||||||
|
r.Checks = append(r.Checks, c)
|
||||||
|
}
|
||||||
|
|
||||||
// Problems counts failed checks.
|
// Problems counts failed checks.
|
||||||
func (r Report) Problems() int {
|
func (r Report) Problems() int {
|
||||||
n := 0
|
n := 0
|
||||||
@@ -148,9 +159,26 @@ func (r Report) Write(w io.Writer, asJSON bool) error {
|
|||||||
}
|
}
|
||||||
fmt.Fprintln(tw)
|
fmt.Fprintln(tw)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(tw, "CHECK\tOK\tNOTE\n")
|
// The AREA and HINT columns only appear when some check uses them,
|
||||||
|
// so the table of a program without them is unchanged.
|
||||||
|
withArea, withHint := false, false
|
||||||
for _, c := range r.Checks {
|
for _, c := range r.Checks {
|
||||||
fmt.Fprintf(tw, "%s\t%s\t%s\n", c.Name, yesNo(c.OK), c.Note)
|
withArea = withArea || c.Area != ""
|
||||||
|
withHint = withHint || c.Hint != ""
|
||||||
|
}
|
||||||
|
row := func(area, name, ok, note, hint string) {
|
||||||
|
cols := []string{name, ok, note}
|
||||||
|
if withArea {
|
||||||
|
cols = append([]string{area}, cols...)
|
||||||
|
}
|
||||||
|
if withHint {
|
||||||
|
cols = append(cols, hint)
|
||||||
|
}
|
||||||
|
fmt.Fprintln(tw, strings.Join(cols, "\t"))
|
||||||
|
}
|
||||||
|
row("AREA", "CHECK", "OK", "NOTE", "HINT")
|
||||||
|
for _, c := range r.Checks {
|
||||||
|
row(c.Area, c.Name, yesNo(c.OK), c.Note, c.Hint)
|
||||||
}
|
}
|
||||||
return tw.Flush()
|
return tw.Flush()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,3 +49,37 @@ func TestAddPaths(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAreaAndHint(t *testing.T) {
|
||||||
|
// Without area/hint neither the JSON nor the table mentions them.
|
||||||
|
plain := Report{Program: "tool"}
|
||||||
|
plain.Check("config valid", true, "")
|
||||||
|
var out strings.Builder
|
||||||
|
if err := plain.Write(&out, true); err != nil || strings.Contains(out.String(), "area") || strings.Contains(out.String(), "hint") {
|
||||||
|
t.Fatalf("plain json: %v %s", err, out.String())
|
||||||
|
}
|
||||||
|
out.Reset()
|
||||||
|
if err := plain.Write(&out, false); err != nil || strings.Contains(out.String(), "AREA") || strings.Contains(out.String(), "HINT") {
|
||||||
|
t.Fatalf("plain table: %v %s", err, out.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
r := Report{Program: "tool"}
|
||||||
|
r.Add(Check{Area: "config", Name: "config loads", OK: false, Note: "line 3", Hint: "run tool config validate"})
|
||||||
|
r.Check("other", true, "")
|
||||||
|
out.Reset()
|
||||||
|
if err := r.Write(&out, true); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var got Report
|
||||||
|
if err := json.Unmarshal([]byte(out.String()), &got); err != nil || got.Checks[0].Area != "config" || got.Checks[0].Hint != "run tool config validate" || got.Checks[1].Area != "" {
|
||||||
|
t.Fatalf("json: %v %+v", err, got)
|
||||||
|
}
|
||||||
|
out.Reset()
|
||||||
|
if err := r.Write(&out, false); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
lines := strings.Split(out.String(), "\n")
|
||||||
|
if !strings.HasPrefix(lines[0], "AREA") || !strings.Contains(lines[0], "HINT") || !strings.HasPrefix(lines[1], "config") || !strings.Contains(lines[1], "run tool config validate") {
|
||||||
|
t.Fatalf("table:\n%s", out.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user