Skip to content

Commit

Permalink
🚑 Fix append of translate_shell.tools.generate_prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Aug 29, 2023
1 parent a49c2bd commit 757de81
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion addon-info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "translate-shell",
"description": "Translate text by google, bing, youdaozhiyun, haici, stardict, openai, large language model of local machine, etc at same time from CLI, GUI (GNU/Linux, Android, macOS and Windows), REPL, python, shell and vim.",
"version": "0.0.33",
"version": "0.0.34",
"author": "Wu Zhenyu <wuzhenyu@ustc.edu>",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "translate-shell",
"version": "0.0.33",
"version": "0.0.34",
"description": "Translate text by google, bing, youdaozhiyun, haici, stardict, openai, large language model of local machine, etc at same time from CLI, GUI (GNU/Linux, Android, macOS and Windows), REPL, python, shell and vim.",
"author": "Wu Zhenyu <wuzhenyu@ustc.edu>",
"license": "GPLv3"
Expand Down
23 changes: 14 additions & 9 deletions src/translate_shell/tools/generate_prompt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
python -m translate_shell.tools.generate_prompt > ~/.config/lftp/lftp/rc
echo 'source ~/.config/lftp/lftp/rc' >> ~/.config/lftp/rc
"""
import os
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from datetime import datetime

Expand All @@ -30,6 +29,15 @@
EPILOG = """
Report bugs to <wuzhenyu@ustc.edu>.
"""
SECTION = [
["BLACK", "YELLOW", r" \s \v"],
["WHITE", "BLACK", r"\S\? 󰀎 \u\?"],
["WHITE", "BLUE", r" \l"],
["BLACK", "WHITE", r" \w"],
]
SECTION_TEXT = "\n".join(
" ".join(["--section"] + [repr(s) for s in section]) for section in SECTION
)


def get_parser() -> ArgumentParser:
Expand Down Expand Up @@ -59,14 +67,9 @@ def get_parser() -> ArgumentParser:
parser.add_argument(
"--section",
nargs="*",
default=[
["BLACK", "YELLOW", r" \s \v"],
["WHITE", "BLACK", r"\S\? 󰀎 \u\?"],
["WHITE", "BLUE", r" \l"],
["BLACK", "WHITE", r" \w"],
],
default=[],
action="append",
help="insert sections. default: %(default)s",
help=f"insert sections. default: {SECTION_TEXT}",
)
return parser

Expand All @@ -80,6 +83,8 @@ def main() -> None:

from ...utils.misc import p10k_sections

if args.section == []:
args.section = SECTION
args.section = [
section[0] if len(section) == 1 else section
for section in args.section
Expand All @@ -88,7 +93,7 @@ def main() -> None:
with sys.stdout as f:
f.write(
args.format.format(
text=p10k_sections(args.section) + args.prompt_string
text=p10k_sections(args.section) + args.prompt_string # type: ignore
)
)

Expand Down

0 comments on commit 757de81

Please sign in to comment.