<commit_before>package main

import (
	"fmt"
	"os"
	"runtime"

	"github.com/jessevdk/go-flags"
	"github.com/nsf/termbox-go"
	"github.com/peco/peco"
)

var version = "v0.1.12"

func showHelp() {
	const v = ` 
Usage: peco [options] [FILE]

Options:
  -h, --help            show this help message and exit
  --version             print the version and exit
  --rcfile=RCFILE       path to the settings file
  --query=QUERY         pre-input query
  --no-ignore-case      start in case-sensitive mode
  -b, --buffer-size     number of lines to keep in search buffer
  --null                expect NUL (\0) as separator for target/output (EXPERIMENTAL)
  --initial-index       position of the initial index of the selection
`
	os.Stderr.Write([]byte(v))
}

type cmdOptions struct {
	OptHelp          bool   `short:"h" long:"help" description:"show this help message and exit"`
	OptTTY           string `long:"tty" description:"path to the TTY (usually, the value of $TTY)"`
	OptQuery         string `long:"query"`
	OptRcfile        string `long:"rcfile" descriotion:"path to the settings file"`
	OptNoIgnoreCase  bool   `long:"no-ignore-case" description:"start in case-sensitive-mode" default:"false"`
	OptVersion       bool   `long:"version" description:"print the version and exit"`
	OptBufferSize    int    `long:"buffer-size" short:"b" description:"number of lines to keep in search buffer"`
	OptEnableNullSep bool   `long:"null" description:"expect NUL (\\0) as separator for target/output"`
	OptInitialIndex  int    `long:"initial-index" description:"position of the initial index of the selection"`
}

// BufferSize returns the specified buffer size. Fulfills peco.CtxOptions
func (o cmdOptions) BufferSize() int {
	return o.OptBufferSize
}

// EnableNullSep returns tru if --null was specified. Fulfills peco.CtxOptions
func (o cmdOptions) EnableNullSep() bool {
	return o.OptEnableNullSep
}

func (o cmdOptions) InitialIndex() int {
	if o.OptInitialIndex > 0 {
		return o.OptInitialIndex
	} else {
		return 1
	}
}

func main() {
	var err error
	var st int

	defer func() { os.Exit(st) }()

	if envvar := os.Getenv("GOMAXPROCS"); envvar == "" {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}

	opts := &cmdOptions{}
	p := flags.NewParser(opts, flags.PrintErrors)
	args, err := p.Parse()
	if err != nil {
		showHelp()
		st = 1
		return
	}<commit_msg>Change number of --initial-index from one-based index to zero-based (same as percol)<commit_after>package main

import (
	"fmt"
	"os"
	"runtime"

	"github.com/jessevdk/go-flags"
	"github.com/nsf/termbox-go"
	"github.com/peco/peco"
)

var version = "v0.1.12"

func showHelp() {
	const v = ` 
Usage: peco [options] [FILE]

Options:
  -h, --help            show this help message and exit
  --version             print the version and exit
  --rcfile=RCFILE       path to the settings file
  --query=QUERY         pre-input query
  --no-ignore-case      start in case-sensitive mode
  -b, --buffer-size     number of lines to keep in search buffer
  --null                expect NUL (\0) as separator for target/output (EXPERIMENTAL)
  --initial-index       position of the initial index of the selection. 0 is first item
`
	os.Stderr.Write([]byte(v))
}

type cmdOptions struct {
	OptHelp          bool   `short:"h" long:"help" description:"show this help message and exit"`
	OptTTY           string `long:"tty" description:"path to the TTY (usually, the value of $TTY)"`
	OptQuery         string `long:"query"`
	OptRcfile        string `long:"rcfile" descriotion:"path to the settings file"`
	OptNoIgnoreCase  bool   `long:"no-ignore-case" description:"start in case-sensitive-mode" default:"false"`
	OptVersion       bool   `long:"version" description:"print the version and exit"`
	OptBufferSize    int    `long:"buffer-size" short:"b" description:"number of lines to keep in search buffer"`
	OptEnableNullSep bool   `long:"null" description:"expect NUL (\\0) as separator for target/output"`
	OptInitialIndex  int    `long:"initial-index" description:"position of the initial index of the selection. 0 is first item"`
}

// BufferSize returns the specified buffer size. Fulfills peco.CtxOptions
func (o cmdOptions) BufferSize() int {
	return o.OptBufferSize
}

// EnableNullSep returns tru if --null was specified. Fulfills peco.CtxOptions
func (o cmdOptions) EnableNullSep() bool {
	return o.OptEnableNullSep
}

func (o cmdOptions) InitialIndex() int {
	if o.OptInitialIndex >= 0 {
		return o.OptInitialIndex + 1
	} else {
		return 1
	}
}

func main() {
	var err error
	var st int

	defer func() { os.Exit(st) }()

	if envvar := os.Getenv("GOMAXPROCS"); envvar == "" {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}

	opts := &cmdOptions{}
	p := flags.NewParser(opts, flags.PrintErrors)
	args, err := p.Parse()
	if err != nil {
		showHelp()
		st = 1
		return
	}
{'fraction_non_alphanumeric': 0.11756138160632543, 'fraction_numerical': 0.004369538077403246, 'mean_word_length': 3.2957998212689903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6838851', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1540, 'n_words': 494}