Fix handling of -q and -s, add pre-commit checks.
This commit is contained in:
+10
-12
@@ -9,6 +9,7 @@ import argparse
|
||||
from .utils import terminal_width, pp, process_tags, display_chat
|
||||
from .storage import save_answers, create_chat, get_tags
|
||||
from .api_client import ai, openai_api_key
|
||||
from itertools import zip_longest
|
||||
|
||||
|
||||
def run_print_command(args: argparse.Namespace, config: dict) -> None:
|
||||
@@ -32,23 +33,20 @@ def process_and_display_chat(args: argparse.Namespace,
|
||||
question_list = args.question if args.question is not None else []
|
||||
source_list = args.source if args.source is not None else []
|
||||
|
||||
for question, source in zip(question_list, source_list):
|
||||
with open(source) as r:
|
||||
question_parts.append(f"{question}\n\n```\n{r.read().strip()}\n```")
|
||||
|
||||
if len(question_list) > len(source_list):
|
||||
for question in question_list[len(source_list):]:
|
||||
for question, source in zip_longest(question_list, source_list, fillvalue=None):
|
||||
if question is not None and source is not None:
|
||||
with open(source) as r:
|
||||
question_parts.append(f"{question}\n\n```\n{r.read().strip()}\n```")
|
||||
elif question is not None:
|
||||
question_parts.append(question)
|
||||
else:
|
||||
for source in source_list[len(question_list):]:
|
||||
elif source is not None:
|
||||
with open(source) as r:
|
||||
question_parts.append(f"```\n{r.read().strip()}\n```")
|
||||
|
||||
question = '\n\n'.join(question_parts)
|
||||
|
||||
chat = create_chat(question, tags, extags, config)
|
||||
full_question = '\n\n'.join(question_parts)
|
||||
chat = create_chat(full_question, tags, extags, config)
|
||||
display_chat(chat, dump, args.only_source_code)
|
||||
return chat, question, tags
|
||||
return chat, full_question, tags
|
||||
|
||||
|
||||
def handle_question(args: argparse.Namespace,
|
||||
|
||||
Reference in New Issue
Block a user