Skip to content

Commit 696a1e2

Browse files
committed
Improve first-run CLI UX and readable output run folders
1 parent bec1c73 commit 696a1e2

5 files changed

Lines changed: 1328 additions & 161 deletions

File tree

e2e/run_e2e_test.go

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ func TestE2ESingleURLSuccess(t *testing.T) {
5050
t.Fatalf("Run() error = %v; stderr=%s", err, stderr.String())
5151
}
5252

53-
matches, err := filepath.Glob(filepath.Join(tmpDir, "out", "*.md"))
54-
if err != nil {
55-
t.Fatalf("glob output file: %v", err)
56-
}
57-
if len(matches) != 1 {
58-
t.Fatalf("output files len=%d, want 1", len(matches))
53+
paths := outputPathsFromStdout(stdout.String())
54+
if len(paths) == 0 {
55+
t.Fatalf("stdout missing output path: %s", stdout.String())
5956
}
6057

61-
content, err := os.ReadFile(matches[0])
58+
content, err := os.ReadFile(paths[0])
6259
if err != nil {
6360
t.Fatalf("read output: %v", err)
6461
}
@@ -111,7 +108,7 @@ func TestE2EMultiURLPartialFailure(t *testing.T) {
111108
t.Fatalf("Run() error = nil, want partial-failure error")
112109
}
113110

114-
summaryPath := filepath.Join(tmpDir, "out", "_summary.json")
111+
summaryPath := summaryPathFromStdout(t, stdout.String())
115112
summaryData, readErr := os.ReadFile(summaryPath)
116113
if readErr != nil {
117114
t.Fatalf("read summary: %v", readErr)
@@ -295,3 +292,39 @@ func sampleLongArticle(title string) string {
295292
b.WriteString("</article></body></html>")
296293
return b.String()
297294
}
295+
296+
func summaryPathFromStdout(t *testing.T, stdout string) string {
297+
t.Helper()
298+
299+
for _, line := range strings.Split(stdout, "\n") {
300+
trimmed := strings.TrimSpace(line)
301+
if strings.HasPrefix(trimmed, "Summary: ") {
302+
path := strings.TrimSpace(strings.TrimPrefix(trimmed, "Summary: "))
303+
if path != "" {
304+
return path
305+
}
306+
}
307+
}
308+
t.Fatalf("stdout missing summary path: %s", stdout)
309+
return ""
310+
}
311+
312+
func outputPathsFromStdout(stdout string) []string {
313+
paths := make([]string, 0, 2)
314+
for _, line := range strings.Split(stdout, "\n") {
315+
trimmed := strings.TrimSpace(line)
316+
if idx := strings.Index(trimmed, "Output: "); idx >= 0 {
317+
path := strings.TrimSpace(trimmed[idx+len("Output: "):])
318+
if path != "" {
319+
paths = append(paths, path)
320+
}
321+
}
322+
if idx := strings.Index(trimmed, "Output (HTML): "); idx >= 0 {
323+
path := strings.TrimSpace(trimmed[idx+len("Output (HTML): "):])
324+
if path != "" {
325+
paths = append(paths, path)
326+
}
327+
}
328+
}
329+
return paths
330+
}

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ require (
1515
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
1616
github.com/go-shiori/dom v0.0.0-20230515143342-73569d674e1c // indirect
1717
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f // indirect
18+
golang.org/x/sys v0.41.0 // indirect
19+
golang.org/x/term v0.40.0 // indirect
1820
golang.org/x/text v0.31.0 // indirect
1921
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7373
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7474
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7575
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
76+
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
77+
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
7678
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
7779
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
7880
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -82,6 +84,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
8284
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
8385
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
8486
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
87+
golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
88+
golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM=
8589
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8690
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
8791
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=

0 commit comments

Comments
 (0)