|
|
""" |
|
|
Help command for the Folio CLI. |
|
|
|
|
|
This module provides the help command for displaying information about available commands. |
|
|
""" |
|
|
|
|
|
from typing import Any |
|
|
|
|
|
from rich.box import ROUNDED |
|
|
from rich.table import Table |
|
|
|
|
|
|
|
|
def help_command(args: list[str], state: dict[str, Any], console): |
|
|
"""Show help information. |
|
|
|
|
|
Args: |
|
|
args: Command arguments |
|
|
state: Application state |
|
|
console: Rich console for output |
|
|
""" |
|
|
from src.focli.commands import get_command_registry |
|
|
|
|
|
|
|
|
commands = get_command_registry() |
|
|
|
|
|
|
|
|
if args and args[0] in commands: |
|
|
command = args[0] |
|
|
command_info = commands[command] |
|
|
|
|
|
console.print(f"\n[bold]Help for command:[/bold] [cyan]{command}[/cyan]") |
|
|
console.print(f"\n{command_info['help']}\n") |
|
|
|
|
|
|
|
|
if command_info.get("subcommands"): |
|
|
console.print("[bold]Subcommands:[/bold]") |
|
|
for subcommand in command_info["subcommands"]: |
|
|
console.print(f" [cyan]{subcommand}[/cyan]") |
|
|
console.print("") |
|
|
|
|
|
|
|
|
console.print("[bold]Usage examples:[/bold]") |
|
|
|
|
|
if command == "simulate": |
|
|
console.print( |
|
|
" [green]simulate[/green] - Run a simulation with default parameters (SPY benchmark)" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate --range 10 --steps 21[/green] - Run a simulation with ±10% range and 21 steps" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate --focus SPY,AAPL[/green] - Run a simulation focusing on specific tickers" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate --detailed[/green] - Run a simulation with detailed position analysis" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate --preset detailed[/green] - Run a simulation using a saved preset" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate --save-preset my_preset[/green] - Save current parameters as a preset" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate --filter options[/green] - Run a simulation only on positions with options" |
|
|
) |
|
|
console.print( |
|
|
" [green]simulate spy[/green] - Explicitly specify SPY benchmark (same as 'simulate')" |
|
|
) |
|
|
|
|
|
elif command == "position": |
|
|
console.print( |
|
|
" [green]position SPY[/green] - Show details for the SPY position" |
|
|
) |
|
|
console.print( |
|
|
" [green]position AAPL details --detailed[/green] - Show detailed information for the AAPL position" |
|
|
) |
|
|
console.print( |
|
|
" [green]position SPY risk[/green] - Show risk analysis for the SPY position" |
|
|
) |
|
|
console.print( |
|
|
" [green]position AAPL simulate[/green] - Simulate the AAPL position with SPY changes" |
|
|
) |
|
|
console.print( |
|
|
" [green]position AAPL simulate --range 15 --steps 11[/green] - Customize the position simulation" |
|
|
) |
|
|
|
|
|
elif command == "portfolio": |
|
|
console.print( |
|
|
" [green]portfolio[/green] - Show a summary of the portfolio (same as 'portfolio summary')" |
|
|
) |
|
|
console.print( |
|
|
" [green]portfolio summary[/green] - Show a summary of the portfolio" |
|
|
) |
|
|
console.print( |
|
|
" [green]portfolio load path/to/portfolio.csv[/green] - Load a portfolio from a CSV file" |
|
|
) |
|
|
console.print( |
|
|
" [green]portfolio list[/green] - List all positions in the portfolio" |
|
|
) |
|
|
console.print( |
|
|
" [green]portfolio list --focus SPY,AAPL[/green] - List specific positions" |
|
|
) |
|
|
console.print( |
|
|
" [green]portfolio list --options[/green] - List only positions with options" |
|
|
) |
|
|
console.print( |
|
|
" [green]portfolio list --sort value[/green] - Sort positions by value" |
|
|
) |
|
|
|
|
|
elif command == "help": |
|
|
console.print(" [green]help[/green] - Show this help message") |
|
|
console.print( |
|
|
" [green]help simulate[/green] - Show help for the simulate command" |
|
|
) |
|
|
|
|
|
elif command == "exit": |
|
|
console.print(" [green]exit[/green] - Exit the application") |
|
|
|
|
|
console.print("") |
|
|
|
|
|
else: |
|
|
|
|
|
console.print("\n[bold cyan]Folio CLI Help[/bold cyan]") |
|
|
console.print("\nAvailable commands:\n") |
|
|
|
|
|
|
|
|
table = Table(box=ROUNDED) |
|
|
table.add_column("Command", style="cyan") |
|
|
table.add_column("Description", style="green") |
|
|
table.add_column("Subcommands", style="yellow") |
|
|
|
|
|
|
|
|
for name, info in commands.items(): |
|
|
subcommands = ( |
|
|
", ".join(info.get("subcommands", [])) |
|
|
if info.get("subcommands") |
|
|
else "" |
|
|
) |
|
|
table.add_row(name, info["help"], subcommands) |
|
|
|
|
|
console.print(table) |
|
|
|
|
|
|
|
|
console.print("\n[bold]General usage:[/bold]") |
|
|
console.print(" Type a command followed by any arguments or options.") |
|
|
console.print( |
|
|
" Use [cyan]help <command>[/cyan] to get help for a specific command." |
|
|
) |
|
|
console.print(" Use [cyan]exit[/cyan] to exit the application.") |
|
|
console.print("") |
|
|
|