mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-06 08:01:58 +02:00
...
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
// Option {{{
|
||||
type OptionType int
|
||||
|
||||
const (
|
||||
@@ -37,6 +38,16 @@ func (self *Alias) String() string {
|
||||
return "--" + self.NameWithoutHyphens
|
||||
}
|
||||
|
||||
type OptionSpec struct {
|
||||
Name string
|
||||
Type string
|
||||
Dest string
|
||||
Choices string
|
||||
Depth int
|
||||
Default string
|
||||
Help string
|
||||
}
|
||||
|
||||
type Option struct {
|
||||
Name string
|
||||
Aliases []Alias
|
||||
@@ -170,6 +181,9 @@ func (self *Option) add_value(val string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// Groups {{{
|
||||
type CommandGroup struct {
|
||||
SubCommands []*Command
|
||||
Title string
|
||||
@@ -204,17 +218,7 @@ func (self *CommandGroup) FindSubCommand(name string) *Command {
|
||||
return nil
|
||||
}
|
||||
|
||||
type OptionSpec struct {
|
||||
Name string
|
||||
Type string
|
||||
Dest string
|
||||
Choices string
|
||||
Depth int
|
||||
Default string
|
||||
Help string
|
||||
}
|
||||
|
||||
type OptionGroup struct { // {{{
|
||||
type OptionGroup struct {
|
||||
Options []*Option
|
||||
Title string
|
||||
}
|
||||
@@ -258,7 +262,7 @@ func (self *OptionGroup) FindOption(name_with_hyphens string) *Option {
|
||||
|
||||
// }}}
|
||||
|
||||
type Command struct {
|
||||
type Command struct { // {{{
|
||||
Name, ExeName string
|
||||
Usage, HelpText string
|
||||
Hidden bool
|
||||
@@ -542,3 +546,5 @@ func (self *Command) GetOptionValues(pointer_to_options_struct any) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
@@ -17,8 +17,16 @@ type SubMatch struct {
|
||||
Start, End int
|
||||
}
|
||||
|
||||
func Compile(pat string) (*regexp.Regexp, error) {
|
||||
return pat_cache.GetOrCreate(pat, regexp.Compile)
|
||||
}
|
||||
|
||||
func MustCompile(pat string) *regexp.Regexp {
|
||||
return pat_cache.MustGetOrCreate(pat, regexp.MustCompile)
|
||||
}
|
||||
|
||||
func ReplaceAll(pat, str string, repl func(full_match string, groupdict map[string]SubMatch) string) string {
|
||||
cpat := pat_cache.MustGetOrCreate(pat, regexp.MustCompile)
|
||||
cpat := MustCompile(pat)
|
||||
result := strings.Builder{}
|
||||
result.Grow(len(str) + 256)
|
||||
last_index := 0
|
||||
|
||||
Reference in New Issue
Block a user