2018-03-19 04:24:54 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2018-04-02 17:01:51 +08:00
|
|
|
"strings"
|
2018-03-19 04:24:54 +08:00
|
|
|
|
2018-03-21 07:27:45 +08:00
|
|
|
"github.com/rivo/tview"
|
2018-03-19 04:24:54 +08:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
RootCmd = &cobra.Command{
|
|
|
|
Use: "service-monitor",
|
|
|
|
Short: "service-monitor monitors systemd Units",
|
|
|
|
Long: "service-monitor is a convenient little tool to monitor systemd Units",
|
|
|
|
SilenceErrors: false,
|
|
|
|
SilenceUsage: true,
|
2018-03-24 11:28:29 +08:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return logsCmd.RunE(cmd, args)
|
|
|
|
},
|
2018-03-19 04:24:54 +08:00
|
|
|
}
|
2018-03-21 07:27:45 +08:00
|
|
|
|
|
|
|
apperr error
|
|
|
|
app = tview.NewApplication()
|
2018-03-24 14:23:24 +08:00
|
|
|
menu = NewMenu(app)
|
2018-04-02 17:01:51 +08:00
|
|
|
|
|
|
|
search string
|
|
|
|
themeArg string
|
2018-03-19 04:24:54 +08:00
|
|
|
)
|
|
|
|
|
2018-04-02 17:01:51 +08:00
|
|
|
func parseTheme() {
|
|
|
|
switch strings.ToLower(themeArg) {
|
|
|
|
case "ice":
|
|
|
|
theme = IceTheme
|
|
|
|
case "terminal":
|
|
|
|
theme = TerminalTheme
|
|
|
|
default:
|
|
|
|
panic("no such theme: " + themeArg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 04:24:54 +08:00
|
|
|
func main() {
|
2018-04-02 17:01:51 +08:00
|
|
|
RootCmd.PersistentFlags().StringVar(&themeArg, "theme", "terminal", "color scheme (ice, terminal)")
|
|
|
|
cobra.OnInitialize(parseTheme)
|
|
|
|
|
2018-03-19 04:24:54 +08:00
|
|
|
if err := RootCmd.Execute(); err != nil {
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
}
|