cmm: added options '--tight' and '--no-paging' to the 'hist --print' cmd
This commit was merged in pull request #16.
This commit is contained in:
@@ -256,13 +256,16 @@ class Chat:
|
||||
|
||||
def print(self, source_code_only: bool = False,
|
||||
with_metadata: bool = False,
|
||||
paged: bool = True) -> None:
|
||||
paged: bool = True,
|
||||
tight: bool = False) -> None:
|
||||
output: list[str] = []
|
||||
for message in self.messages:
|
||||
if source_code_only:
|
||||
output.append(message.to_str(source_code_only=True))
|
||||
continue
|
||||
output.append(message.to_str(with_metadata))
|
||||
if not tight:
|
||||
output.append('\n' + ('-' * terminal_width()) + '\n')
|
||||
if paged:
|
||||
print_paged('\n'.join(output))
|
||||
else:
|
||||
|
||||
@@ -57,7 +57,9 @@ def print_chat(args: argparse.Namespace, config: Config) -> None:
|
||||
Path(config.db),
|
||||
mfilter=mfilter)
|
||||
chat.print(args.source_code_only,
|
||||
args.with_metadata)
|
||||
args.with_metadata,
|
||||
paged=not args.no_paging,
|
||||
tight=args.tight)
|
||||
|
||||
|
||||
def hist_cmd(args: argparse.Namespace, config: Config) -> None:
|
||||
|
||||
@@ -85,6 +85,8 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
action='store_true')
|
||||
hist_cmd_parser.add_argument('-A', '--answer', help='Print only answers with given substring', metavar='SUBSTRING')
|
||||
hist_cmd_parser.add_argument('-Q', '--question', help='Print only questions with given substring', metavar='SUBSTRING')
|
||||
hist_cmd_parser.add_argument('-d', '--tight', help='Print without message separators', action='store_true')
|
||||
hist_cmd_parser.add_argument('-P', '--no-paging', help='Print without paging', action='store_true')
|
||||
|
||||
# 'tags' command parser
|
||||
tags_cmd_parser = cmdparser.add_parser('tags',
|
||||
|
||||
Reference in New Issue
Block a user