You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📊 Enhance table display and fix help formatting for v2.1.0
This commit includes several improvements for the v2.1.0 release:
- Fix compilation issues with help text formatting by replacing backtick concatenation with double quotes
- Optimize table display for queries with many labels:
- Limit displayed columns to 10 (metric + 8 labels + value)
- Truncate long headers and values for better readability
- Implement intelligent column limiting for wide tables
- Add emojis to feature and tips sections for improved visual appeal
- Reorganize tips display to show before Prometheus connection
- Update README with v2.1.0 release notes and new features
- Improve alignment of command-line options in help output
These enhancements make the application more robust and user-friendly, particularly when working with complex metrics containing numerous labels.
// enableLabelValues controls whether label values autocompletion is enabled.
28
+
// Autocompletion Flags
35
29
enableLabelValues=kingpin.Flag("enable-label-values", "Enable autocompletion for label values.").Default("true").Bool()
36
30
37
-
// debug enables verbose error output for debugging purposes.
38
-
debug=kingpin.Flag("debug", "Enable verbose error output for debugging.").Bool()
39
-
40
-
// historyFile specifies the path to the command history file.
41
-
historyFile=kingpin.Flag("history-file", "Path to the command history file. If not set, a temporary file is used.\n").String()
42
-
43
-
// persistHistory determines whether the history file should be persisted across sessions.
44
-
persistHistory=kingpin.Flag("persist-history", "Do not delete the history file on exit. Only applicable if --history-file is set or a temporary file is used.\n").Bool()
31
+
// History Flags
32
+
historyFile=kingpin.Flag("history-file", "Path to the command history file.").String()
33
+
persistHistory=kingpin.Flag("persist-history", "Do not delete the history file on exit.").Bool()
45
34
46
-
// tips enables the display of detailed feature and usage tips on startup.
47
-
tips=kingpin.Flag("tips", "Display detailed feature and usage tips on startup.").Bool()
35
+
// Display and Utility Flags
36
+
debug=kingpin.Flag("debug", "Enable verbose error output for debugging.").Bool()
37
+
tips=kingpin.Flag("tips", "Display detailed feature and usage tips on startup.").Bool()
48
38
)
49
39
50
40
// main is the entry point of the Prometheus CLI application.
@@ -55,6 +45,13 @@ func main() {
55
45
kingpin.HelpFlag.Short('h')
56
46
kingpin.Parse()
57
47
48
+
// Display welcome message and feature information if tips are enabled
49
+
if*tips {
50
+
printWelcomeMessage()
51
+
} else {
52
+
fmt.Println("Enter Prometheus queries. Press Ctrl+C to exit.")
53
+
}
54
+
58
55
// Initialize Prometheus client with user-provided configuration
59
56
if*debug {
60
57
fmt.Printf("Debug: Setting Prometheus URL to %s/api/v1\n", *url)
@@ -67,15 +64,15 @@ func main() {
67
64
68
65
// Load available metrics from Prometheus for autocompletion
69
66
fmt.Print("Loading metrics...")
70
-
metrics, err:=prometheus.GetMetrics()
71
-
iferr!=nil {
72
-
if*debug {
73
-
fmt.Printf("\rError getting metrics: %v\n", err)
74
-
} else {
75
-
fmt.Printf("\rError getting metrics. Use --debug for more details.\n")
76
-
}
77
-
os.Exit(1)
67
+
metrics, err:=prometheus.GetMetrics()
68
+
iferr!=nil {
69
+
if*debug {
70
+
fmt.Printf("\rError getting metrics: %v\n", err)
71
+
} else {
72
+
fmt.Printf("\rError getting metrics. Use --debug for more details.\n")
0 commit comments