Merge pull request #49 from kwmiebach/main

Add program argument for syntax highlighting theme.
This commit is contained in:
paul-gauthier 2023-07-05 06:46:04 -07:00 committed by GitHub
commit cdf8f9a4b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -111,6 +111,7 @@ class Coder:
map_tokens=1024, map_tokens=1024,
verbose=False, verbose=False,
assistant_output_color="blue", assistant_output_color="blue",
code_theme="default",
stream=True, stream=True,
use_git=True, use_git=True,
): ):
@ -135,6 +136,7 @@ class Coder:
self.auto_commits = auto_commits self.auto_commits = auto_commits
self.dirty_commits = dirty_commits self.dirty_commits = dirty_commits
self.assistant_output_color = assistant_output_color self.assistant_output_color = assistant_output_color
self.code_theme = code_theme
self.dry_run = dry_run self.dry_run = dry_run
self.pretty = pretty self.pretty = pretty
@ -679,7 +681,7 @@ class Coder:
show_resp = self.render_incremental_response(True) show_resp = self.render_incremental_response(True)
if self.pretty: if self.pretty:
show_resp = Markdown(show_resp, style=self.assistant_output_color, code_theme="default") show_resp = Markdown(show_resp, style=self.assistant_output_color, code_theme=self.code_theme)
else: else:
show_resp = Text(show_resp or "<no response>") show_resp = Text(show_resp or "<no response>")
@ -735,7 +737,7 @@ class Coder:
if not show_resp: if not show_resp:
return return
md = Markdown(show_resp, style=self.assistant_output_color, code_theme="default") md = Markdown(show_resp, style=self.assistant_output_color, code_theme=self.code_theme)
live.update(md) live.update(md)
def render_incremental_response(self, final): def render_incremental_response(self, final):

View file

@ -145,6 +145,11 @@ def main(args=None, input=None, output=None):
default="blue", default="blue",
help="Set the color for assistant output (default: blue)", help="Set the color for assistant output (default: blue)",
) )
parser.add_argument(
"--code-theme",
default="default",
help="Set the markdown code theme (default: default, other options include monokai, solarized-dark, solarized-light)",
)
parser.add_argument( parser.add_argument(
"--apply", "--apply",
metavar="FILE", metavar="FILE",
@ -272,6 +277,7 @@ def main(args=None, input=None, output=None):
map_tokens=args.map_tokens, map_tokens=args.map_tokens,
verbose=args.verbose, verbose=args.verbose,
assistant_output_color=args.assistant_output_color, assistant_output_color=args.assistant_output_color,
code_theme=args.code_theme,
stream=args.stream, stream=args.stream,
use_git=args.git, use_git=args.git,
) )