1010from typing import Dict , List , Tuple , Union , Sequence
1111from typing import Optional , Any , TYPE_CHECKING
1212
13- from aiostream import stream
1413from attrs import evolve
1514from parsy import Parser
1615from rich .padding import Padding
1716
1817from fixcore import version
1918from fixcore .analytics import CoreEvent
20- from fixcore .cli import cmd_with_args_parser , key_values_parser , T , Sink , args_values_parser , JsGen
19+ from fixcore .cli import cmd_with_args_parser , key_values_parser , T , Sink , args_values_parser , JsStream
2120from fixcore .cli .command import (
2221 SearchPart ,
2322 PredecessorsPart ,
7877from fixcore .types import JsonElement
7978from fixcore .user .model import Permission
8079from fixcore .util import group_by
80+ from fixlib .asynchronous .stream import Stream
8181from fixlib .parse_util import make_parser , pipe_p , semicolon_p
8282
8383if TYPE_CHECKING :
@@ -104,7 +104,7 @@ def command_line_parser() -> Parser:
104104 return ParsedCommands (commands , maybe_env if maybe_env else {})
105105
106106
107- # multiple piped commands are separated by semicolon
107+ # semicolon separates multiple piped commands
108108multi_command_parser = command_line_parser .sep_by (semicolon_p )
109109
110110
@@ -187,7 +187,7 @@ def overview() -> str:
187187 logo = ctx .render_console (Padding (WelcomeCommand .ck , pad = (0 , 0 , 0 , middle ))) if ctx .supports_color () else ""
188188 return headline + logo + ctx .render_console (result )
189189
190- def help_command () -> JsGen :
190+ def help_command () -> JsStream :
191191 if not arg :
192192 result = overview ()
193193 elif arg == "placeholders" :
@@ -209,7 +209,7 @@ def help_command() -> JsGen:
209209 else :
210210 result = f"No command found with this name: { arg } "
211211
212- return stream .just (result )
212+ return Stream .just (result )
213213
214214 return CLISource .single (help_command , required_permissions = {Permission .read })
215215
@@ -352,11 +352,11 @@ def command(
352352 self , name : str , arg : Optional [str ] = None , ctx : CLIContext = EmptyContext , ** kwargs : Any
353353 ) -> ExecutableCommand :
354354 """
355- Create an executable command for given command name, args and context.
356- :param name: the name of the command to execute (must be a known command)
357- :param arg: the arg of the command (must be parsable by the command)
358- :param ctx: the context of this command.
359- :return: the ready to run executable command.
355+ Create an executable command for given command name, args, and context.
356+ :param name: The name of the command to execute (must be a known command).
357+ :param arg: The arg of the command (must be parsable by the command).
358+ :param ctx: The context of this command.
359+ :return: The ready to run executable command.
360360 :raises:
361361 CLIParseError: if the name of the command is not known, or the argument fails to parse.
362362 """
@@ -377,9 +377,9 @@ async def create_query(
377377 Takes a list of query part commands and combine them to a single executable query command.
378378 This process can also introduce new commands that should run after the query is finished.
379379 Therefore, a list of executable commands is returned.
380- :param commands: the incoming executable commands, which actions are all instances of SearchCLIPart.
381- :param ctx: the context to execute within.
382- :return: the resulting list of commands to execute.
380+ :param commands: The incoming executable commands, which actions are all instances of SearchCLIPart.
381+ :param ctx: The context to execute within.
382+ :return: The resulting list of commands to execute.
383383 """
384384
385385 # Pass parsed options to execute query
@@ -484,8 +484,8 @@ async def parse_query(query_arg: str) -> Query:
484484 first_head_tail_in_a_row = None
485485 head_tail_keep_order = True
486486
487- # Define default sort order, if not already defined
488- # A sort order is required to always return the result in a deterministic way to the user.
487+ # Define default sort order, if not already defined.
488+ # A sort order is required to always return the result deterministically to the user.
489489 # Deterministic order is required for head/tail to work
490490 if query .is_simple_fulltext_search ():
491491 # Do not define any additional sort order for fulltext searches
@@ -494,7 +494,7 @@ async def parse_query(query_arg: str) -> Query:
494494 parts = [pt if pt .sort else evolve (pt , sort = default_sort ) for pt in query .parts ]
495495 query = evolve (query , parts = parts )
496496
497- # If the last part is a navigation, we need to add sort which will ingest a new part.
497+ # If the last part is a navigation, we need to add a sort which will ingest a new part.
498498 with_sort = query .set_sort (* default_sort ) if query .current_part .navigation else query
499499 section = ctx .env .get ("section" , PathRoot )
500500 # If this is an aggregate query, the default sort needs to be changed
@@ -534,7 +534,7 @@ def rewrite_command_line(cmds: List[ExecutableCommand], ctx: CLIContext) -> List
534534 Rules:
535535 - add the list command if no output format is defined
536536 - add a format to write commands if no output format is defined
537- - report benchmark run will be formatted as benchmark result automatically
537+ - report benchmark run will be formatted as a benchmark result automatically
538538 """
539539 if ctx .env .get ("no_rewrite" ) or len (cmds ) == 0 :
540540 return cmds
0 commit comments