Skip to content

Commit a4e2794

Browse files
docs(cli): enhance help output with features and examples
Updates the `lv --help` documentation to be more comprehensive and professional. Key changes: - Expanded project description to highlight performance capabilities. - Added a detailed list of key features (Virtualization, Time Travel, Filtering). - Added practical usage examples for files, Docker, and Kubernetes pipes.
1 parent 6ed12d7 commit a4e2794

2 files changed

Lines changed: 86 additions & 29 deletions

File tree

cmd/root.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,24 @@ import (
1313

1414
var rootCmd = &cobra.Command{
1515
Use: "lv [file]",
16-
Short: "Log Viewer is a TUI for viewing log files",
17-
Long: `A fast and interactive Log Viewer built with Bubbletea.`,
16+
Short: "High-performance TUI for log analysis",
17+
Long: `lv is a blazing fast terminal-based log viewer designed for developers and DevOps.
18+
19+
Key Features:
20+
- Instant loading of large files (GB+) via virtualization.
21+
- Interactive filtering (fuzzy & regex) and time-range drill-down.
22+
- "Time Travel": Jump directly to a specific timestamp (press 'J').
23+
- Stack trace folding for cleaner error analysis.
24+
- Follow mode (tail -f) with auto-scroll.
25+
- Mouse support for scrolling and selection.
26+
- Rich keyboard shortcuts (vim-like navigation).`,
27+
Example: ` # Open a local file
28+
lv app.log
29+
30+
# Pipe logs from stdin
31+
kubectl logs -f my-pod | lv
32+
docker logs my-container | lv
33+
cat large.log | lv`,
1834
Args: cobra.MaximumNArgs(1),
1935
Run: func(cmd *cobra.Command, args []string) {
2036
var lines []string

internal/ui/model.go

Lines changed: 68 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,36 +1225,77 @@ func max(a, b int) int {
12251225
}
12261226

12271227
func (m Model) helpView() string {
1228-
helpRequest := []struct {
1229-
key, desc string
1230-
}{
1231-
{"?", "Toggle Help"},
1232-
{"q / esc", "Quit / Close Help"},
1233-
{"/", "Filter Logs"},
1234-
{"f", "Toggle Follow"},
1235-
{"j / k", "Scroll Down / Up"},
1236-
{"g / G", "Scroll Top / Bottom"},
1237-
{"m", "Toggle Bookmark"},
1228+
// Define helper struct for keys
1229+
type helpEntry struct {
1230+
key, desc string
1231+
}
1232+
1233+
// Group keys
1234+
general := []helpEntry{
1235+
{"?", "Close Help"},
1236+
{"q / esc", "Quit / Close"},
1237+
{"ctrl+c", "Quit"},
1238+
}
1239+
1240+
nav := []helpEntry{
1241+
{"j / k", "Scroll Down / Up"},
1242+
{"g / G", "Scroll Top / Bottom"},
1243+
{"f", "Toggle Follow"},
12381244
{"J", "Jump to Time"},
1245+
{"space", "Page Down"},
1246+
{"b / u", "PgUp / PgDown"},
1247+
}
1248+
1249+
filtering := []helpEntry{
1250+
{"/", "Filter Logs"},
1251+
{"c", "Clear Filters"},
1252+
{"R", "Regex Toggle"},
1253+
{"s / e", "Set Start / End (Time)"},
1254+
{"1-4", "Toggle Levels (Err/Warn...)"},
1255+
}
1256+
1257+
viewing := []helpEntry{
1258+
{"w", "Toggle Wrap"},
1259+
{"z", "Fold Stack Traces"},
12391260
{"t", "Toggle Timeline"},
1261+
{"m", "Toggle Bookmark"},
1262+
{"l / h", "Scroll Right / Left"},
12401263
{"r", "Reload File"},
1241-
{"c", "Clear Filters"},
1242-
}
1243-
1244-
s := lipgloss.NewStyle().
1245-
Border(lipgloss.RoundedBorder()).
1246-
BorderForeground(lipgloss.Color("62")).
1247-
Padding(1, 2)
1248-
1249-
var b strings.Builder
1250-
b.WriteString(lipgloss.NewStyle().Bold(true).Render("Keyboard Shortcuts"))
1251-
b.WriteString("\n\n")
1264+
}
12521265

1253-
for _, h := range helpRequest {
1254-
key := lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Width(12).Render(h.key)
1255-
desc := lipgloss.NewStyle().Foreground(lipgloss.Color("240")).Render(h.desc)
1256-
b.WriteString(fmt.Sprintf("%s %s\n", key, desc))
1257-
}
1266+
// Styles
1267+
boxStyle := lipgloss.NewStyle().
1268+
Border(lipgloss.RoundedBorder()).
1269+
BorderForeground(lipgloss.Color("62")).
1270+
Padding(1, 2).
1271+
Margin(1)
1272+
1273+
headerStyle := lipgloss.NewStyle().
1274+
Foreground(lipgloss.Color("240")).
1275+
Bold(true).
1276+
Underline(true).
1277+
MarginBottom(1)
1278+
1279+
keyStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
1280+
descStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("252"))
1281+
1282+
// Helper to render a column
1283+
renderColumn := func(title string, entries []helpEntry) string {
1284+
s := headerStyle.Render(title) + "\n"
1285+
for _, e := range entries {
1286+
k := keyStyle.Width(10).Render(e.key)
1287+
d := descStyle.Render(e.desc)
1288+
s += fmt.Sprintf("%s %s\n", k, d)
1289+
}
1290+
return s
1291+
}
1292+
1293+
// Layout
1294+
col1 := renderColumn("General", general) + "\n" + renderColumn("Navigation", nav)
1295+
col2 := renderColumn("Filtering", filtering) + "\n" + renderColumn("View & Tools", viewing)
1296+
1297+
// Join columns with gap
1298+
content := lipgloss.JoinHorizontal(lipgloss.Top, col1, " ", col2)
12581299

1259-
return s.Render(b.String())
1300+
return boxStyle.Render(content)
12601301
}

0 commit comments

Comments
 (0)