diff options
author | hjoaquim <h.joaquim@campus.fct.unl.pt> | 2024-05-03 17:33:26 +0100 |
---|---|---|
committer | hjoaquim <h.joaquim@campus.fct.unl.pt> | 2024-05-03 17:33:26 +0100 |
commit | e9b09b82a0f04b39d203453b65f19f558b0850a4 (patch) | |
tree | 50accf26233818c9666a821b7396f191b132d39c | |
parent | 73fd87fdf6cdd30b7802d15a04da040cac171c25 (diff) |
help message on results
-rw-r--r-- | cli/openbb_cli/controllers/base_controller.py | 27 | ||||
-rw-r--r-- | cli/openbb_cli/controllers/cli_controller.py | 11 |
2 files changed, 27 insertions, 11 deletions
diff --git a/cli/openbb_cli/controllers/base_controller.py b/cli/openbb_cli/controllers/base_controller.py index a3d8b20aa16..b8eef6d0b2c 100644 --- a/cli/openbb_cli/controllers/base_controller.py +++ b/cli/openbb_cli/controllers/base_controller.py @@ -9,6 +9,7 @@ from datetime import datetime from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Union +import pandas as pd from openbb_cli.config import setup from openbb_cli.config.completer import NestedCompleter from openbb_cli.config.constants import SCRIPT_TAGS @@ -20,6 +21,7 @@ from openbb_cli.controllers.utils import ( get_flair_and_username, parse_and_split_input, print_guest_block_msg, + print_rich_table, remove_file, system_clear, ) @@ -64,6 +66,7 @@ class BaseController(metaclass=ABCMeta): "stop", "hold", "whoami", + "results", ] CHOICES_COMMANDS: List[str] = [] @@ -732,6 +735,30 @@ class BaseController(metaclass=ABCMeta): else: print_guest_block_msg() + def call_results(self, other_args: List[str]): + """Process results command.""" + parser = argparse.ArgumentParser( + add_help=False, + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + prog="results", + description="Process results command. This command displays a registry of" + "'OBBjects' where all execution results are stored." + "It is organized as a stack, with the most recent result at index 0.", + ) + ns_parser = self.parse_simple_args(parser, other_args) + if ns_parser: + results = session.obbject_registry.all + if results: + df = pd.DataFrame.from_dict(results, orient="index") + print_rich_table( + df, + show_index=True, + index_name="stack index", + title="OBBject Results", + ) + else: + session.console.print("[info]No results found.[/info]") + @staticmethod def parse_simple_args(parser: argparse.ArgumentParser, other_args: List[str]): """Parse list of arguments into the supplied parser. diff --git a/cli/openbb_cli/controllers/cli_controller.py b/cli/openbb_cli/controllers/cli_controller.py index 61e2af1b885..90454da36fa 100644 --- a/cli/openbb_cli/controllers/cli_controller.py +++ b/cli/openbb_cli/controllers/cli_controller.py @@ -474,17 +474,6 @@ class CLIController(BaseController): ) self.queue = self.queue[1:] - def call_results(self, _): - """Process results command.""" - results = session.obbject_registry.all - if results: - df = pd.DataFrame.from_dict(results, orient="index") - print_rich_table( - df, show_index=True, index_name="stack index", title="OBBject Results" - ) - else: - session.console.print("[info]No results found.[/info]") - def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]: """Handle job commands.""" |