From b261de95ca8ca90b6c69149de6f59e3763a10270 Mon Sep 17 00:00:00 2001 From: Noboru Saito Date: Sun, 27 Aug 2023 15:25:38 +0900 Subject: [PATCH] Added option to search by `pattern` option - `--pattern` option is used to search by pattern. Equivalent to less's `--pattern` option. This implements #430. --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 8f19706d..2cb0fb8c 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,8 @@ var ( // config is the oviewer setting. config oviewer.Config + pattern string + // ver is version information. ver bool // helpKey is key bind information. @@ -126,6 +128,10 @@ func RunOviewer(args []string) error { ov.SetConfig(config) + if pattern != "" { + ov.Search(pattern) + } + if err := ov.Run(); err != nil { return err } @@ -371,6 +377,8 @@ func init() { rootCmd.PersistentFlags().StringP("jump-target", "j", "", "jump target `[int|int%|.int|'section']`") _ = viper.BindPFlag("general.JumpTarget", rootCmd.PersistentFlags().Lookup("jump-target")) + rootCmd.PersistentFlags().StringVar(&pattern, "pattern", "", "search pattern") + // Config rootCmd.PersistentFlags().BoolP("disable-mouse", "", false, "disable mouse support") _ = viper.BindPFlag("DisableMouse", rootCmd.PersistentFlags().Lookup("disable-mouse"))