Skip to content

Commit

Permalink
Added option to search by pattern option
Browse files Browse the repository at this point in the history
- `--pattern` option is used to search by pattern.
Equivalent to less's `--pattern` option.
This implements #430.
  • Loading branch information
noborus committed Aug 27, 2023
1 parent 2b48a38 commit b261de9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit b261de9

Please sign in to comment.