DRYer
This commit is contained in:
parent
6b04c42730
commit
654bd23109
@ -86,6 +86,7 @@ def generate_completions_for_kitty() -> None:
|
|||||||
from kitty.config import option_names_for_completion
|
from kitty.config import option_names_for_completion
|
||||||
print('package completion\n')
|
print('package completion\n')
|
||||||
print('import "kitty/tools/cli"')
|
print('import "kitty/tools/cli"')
|
||||||
|
print('import "kitty/tools/cmd/tool"')
|
||||||
print('import "kitty/tools/cmd/at"')
|
print('import "kitty/tools/cmd/at"')
|
||||||
conf_names = ', '.join((f'"{serialize_as_go_string(x)}"' for x in option_names_for_completion()))
|
conf_names = ', '.join((f'"{serialize_as_go_string(x)}"' for x in option_names_for_completion()))
|
||||||
print('var kitty_option_names_for_completion = []string{' + conf_names + '}')
|
print('var kitty_option_names_for_completion = []string{' + conf_names + '}')
|
||||||
@ -96,6 +97,7 @@ def generate_completions_for_kitty() -> None:
|
|||||||
print('k := root.AddSubCommand(&cli.Command{'
|
print('k := root.AddSubCommand(&cli.Command{'
|
||||||
'Name:"kitty", SubCommandIsOptional: true, ArgCompleter: cli.CompleteExecutableFirstArg, SubCommandMustBeFirst: true })')
|
'Name:"kitty", SubCommandIsOptional: true, ArgCompleter: cli.CompleteExecutableFirstArg, SubCommandMustBeFirst: true })')
|
||||||
print('kt := root.AddSubCommand(&cli.Command{Name:"kitty-tool", SubCommandMustBeFirst: true })')
|
print('kt := root.AddSubCommand(&cli.Command{Name:"kitty-tool", SubCommandMustBeFirst: true })')
|
||||||
|
print('tool.KittyToolEntryPoints(kt)')
|
||||||
for opt in go_options_for_seq(parse_option_spec()[0]):
|
for opt in go_options_for_seq(parse_option_spec()[0]):
|
||||||
print(opt.as_option('k'))
|
print(opt.as_option('k'))
|
||||||
|
|
||||||
@ -122,7 +124,6 @@ def generate_completions_for_kitty() -> None:
|
|||||||
|
|
||||||
# @
|
# @
|
||||||
print('at.EntryPoint(k)')
|
print('at.EntryPoint(k)')
|
||||||
print('at.EntryPoint(kt)')
|
|
||||||
|
|
||||||
# clone-in-kitty, edit-in-kitty
|
# clone-in-kitty, edit-in-kitty
|
||||||
print('cik := root.AddSubCommand(&cli.Command{Name:"clone-in-kitty"})')
|
print('cik := root.AddSubCommand(&cli.Command{Name:"clone-in-kitty"})')
|
||||||
|
|||||||
@ -4,8 +4,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"kitty/tools/cli"
|
"kitty/tools/cli"
|
||||||
"kitty/tools/cmd/at"
|
|
||||||
"kitty/tools/cmd/completion"
|
"kitty/tools/cmd/completion"
|
||||||
|
"kitty/tools/cmd/tool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -13,9 +13,7 @@ func main() {
|
|||||||
root.ShortDescription = "Fast, statically compiled implementations for various kitty command-line tools"
|
root.ShortDescription = "Fast, statically compiled implementations for various kitty command-line tools"
|
||||||
root.Usage = "command [command options] [command args]"
|
root.Usage = "command [command options] [command args]"
|
||||||
|
|
||||||
// @
|
tool.KittyToolEntryPoints(root)
|
||||||
at.EntryPoint(root)
|
|
||||||
// __complete__
|
|
||||||
completion.EntryPoint(root)
|
completion.EntryPoint(root)
|
||||||
|
|
||||||
root.Exec()
|
root.Exec()
|
||||||
|
|||||||
17
tools/cmd/tool/main.go
Normal file
17
tools/cmd/tool/main.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
package tool
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"kitty/tools/cli"
|
||||||
|
"kitty/tools/cmd/at"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = fmt.Print
|
||||||
|
|
||||||
|
func KittyToolEntryPoints(root *cli.Command) {
|
||||||
|
// @
|
||||||
|
at.EntryPoint(root)
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user