Skip to content

Commit

Permalink
Update manpages for RH1 (#113)
Browse files Browse the repository at this point in the history
The manpages are updated to ship updated version for RH1
  • Loading branch information
r0x0d authored Jan 15, 2025
1 parent 012e642 commit 0f97d90
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 78 deletions.
6 changes: 3 additions & 3 deletions command_line_assistant/commands/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def register_subcommand(parser: SubParsersAction):
"""
history_parser = parser.add_parser(
"history",
help="Manage conversation history",
help="Manage user conversation history",
)
history_parser.add_argument(
"--clear",
action="store_true",
help="Clear the history.",
help="Clear the entire history.",
)
history_parser.add_argument(
"--first",
Expand All @@ -188,7 +188,7 @@ def register_subcommand(parser: SubParsersAction):
help="Get the last conversation from history.",
)
history_parser.add_argument(
"--filter", help="Search for a specific string of text in the history."
"--filter", help="Search for a specific keyword of text in the history."
)
history_parser.set_defaults(func=_command_factory)

Expand Down
26 changes: 15 additions & 11 deletions command_line_assistant/commands/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ def __init__(
self,
query_string: Optional[str] = None,
stdin: Optional[str] = None,
input: Optional[TextIOWrapper] = None,
attachment: Optional[TextIOWrapper] = None,
) -> None:
"""Constructor of the class.
Args:
query_string (Optional[str], optional): The query provided by the user.
stdin (Optional[str], optional): The user redirect input from stdin
input (Optional[TextIOWrapper], optional): The file input from the user
attachment (Optional[TextIOWrapper], optional): The file attachment from the user
"""
self._query = query_string.strip() if query_string else None
self._stdin = stdin.strip() if stdin else None
self._input = input
self._attachment = attachment

self._spinner_renderer: SpinnerRenderer = create_spinner_renderer(
message="Requesting knowledge from AI",
Expand Down Expand Up @@ -100,8 +100,8 @@ def _get_input_source(self) -> str:
str: The query string from the selected input source(s)
"""
file_content = None
if self._input:
file_content = self._input.read().strip()
if self._attachment:
file_content = self._attachment.read().strip()
if is_content_in_binary_format(file_content):
raise ValueError("File appears to be binary")

Expand Down Expand Up @@ -182,18 +182,18 @@ def register_subcommand(parser: SubParsersAction) -> None:
"""
query_parser = parser.add_parser(
"query",
help="Ask a question and get an answer from LLM.",
help="Command to ask a question to the LLM.",
)
# Positional argument, required only if no optional arguments are provided
query_parser.add_argument(
"query_string", nargs="?", help="Query string to be processed."
"query_string", nargs="?", help="The question that will be sent to the LLM"
)
query_parser.add_argument(
"-i",
"--input",
"-a",
"--attachment",
nargs="?",
type=argparse.FileType("r"),
help="Read file from user system.",
help="File attachment to be read and sent alongside the query",
)

query_parser.set_defaults(func=_command_factory)
Expand All @@ -208,7 +208,11 @@ def _command_factory(args: Namespace) -> QueryCommand:
Returns:
QueryCommand: Return an instance of class
"""
options = {"query_string": args.query_string, "stdin": None, "input": args.input}
options = {
"query_string": args.query_string,
"stdin": None,
"attachment": args.attachment,
}

# We may not always have the stdin argument in the namespace.
if "stdin" in args:
Expand Down
8 changes: 3 additions & 5 deletions command_line_assistant/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,16 @@ def create_argument_parser() -> tuple[ArgumentParser, SubParsersAction]:
"""Create the argument parser for command line assistant."""
parser = ArgumentParser(
prog="c",
description="A script with multiple optional arguments and a required positional argument if no optional arguments are provided.",
description="The Command Line Assistant powered by RHEL Lightspeed is a optional generative AI assistant available within the RHEL command line interface.",
)
parser.add_argument(
"--version",
action="version",
version=VERSION,
default=SUPPRESS,
help="Show command line assistant version and exit.",
)
commands_parser = parser.add_subparsers(
dest="command", help="command line assistant helpers"
help="Show program version",
)
commands_parser = parser.add_subparsers(dest="command")
return parser, commands_parser


Expand Down
Loading

0 comments on commit 0f97d90

Please sign in to comment.