Wire up config infrastructure for diff kitten

This commit is contained in:
Kovid Goyal
2018-04-22 21:44:47 +05:30
parent aa18429a8c
commit b5da109e7f
7 changed files with 144 additions and 33 deletions

View File

@@ -7,13 +7,14 @@ import sys
from functools import partial
from gettext import gettext as _
from kitty.cli import parse_args
from kitty.cli import CONFIG_HELP, appname, parse_args
from kitty.key_encoding import ESCAPE
from ..tui.handler import Handler
from ..tui.loop import Loop
from ..tui.operations import clear_screen, set_line_wrapping, set_window_title
from .collect import create_collection, data_for_path
from .config import init_config
from .git import Differ
from .render import render_diff
@@ -59,6 +60,9 @@ class DiffHandler(Handler):
self.draw_screen()
self.create_collection()
def finalize(self):
pass
def draw_screen(self):
if self.state < DIFFED:
self.write(clear_screen())
@@ -117,7 +121,19 @@ OPTIONS = partial('''\
type=int
default=3
Number of lines of context to show between changes.
'''.format, )
--config
type=list
{config_help}
--override -o
type=list
Override individual configuration options, can be specified multiple times.
Syntax: |_ name=value|. For example: |_ -o background=gray|
'''.format, config_help=CONFIG_HELP.format(conf_name='diff', appname=appname))
def main(args):
@@ -128,6 +144,7 @@ def main(args):
left, right = items
if os.path.isdir(left) != os.path.isdir(right):
raise SystemExit('The items to be diffed should both be either directories or files. Comparing a directory to a file is not valid.')
init_config(args)
loop = Loop()
handler = DiffHandler(args, left, right)