mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-14 11:51:19 +00:00
feat: allow varying help texts for different subcommands
This commit is contained in:
@@ -3,6 +3,7 @@ This module contains the argument manager class
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from argparse import ArgumentParser, Namespace, _ArgumentGroup
|
from argparse import ArgumentParser, Namespace, _ArgumentGroup
|
||||||
|
from copy import deepcopy
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -349,7 +350,11 @@ class Arguments:
|
|||||||
def _build_args(self, optionlist: list[str], parser: ArgumentParser | _ArgumentGroup) -> None:
|
def _build_args(self, optionlist: list[str], parser: ArgumentParser | _ArgumentGroup) -> None:
|
||||||
for val in optionlist:
|
for val in optionlist:
|
||||||
opt = AVAILABLE_CLI_OPTIONS[val]
|
opt = AVAILABLE_CLI_OPTIONS[val]
|
||||||
parser.add_argument(*opt.cli, dest=val, **opt.kwargs)
|
options = deepcopy(opt.kwargs)
|
||||||
|
help_text = options.pop("help", None)
|
||||||
|
if opt.fthelp and isinstance(opt.fthelp, dict):
|
||||||
|
help_text = opt.fthelp.get(parser.prog, help_text)
|
||||||
|
parser.add_argument(*opt.cli, dest=val, help=help_text, **options)
|
||||||
|
|
||||||
def _build_subcommands(self) -> None:
|
def _build_subcommands(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -38,8 +38,14 @@ def check_int_nonzero(value: str) -> int:
|
|||||||
|
|
||||||
class Arg:
|
class Arg:
|
||||||
# Optional CLI arguments
|
# Optional CLI arguments
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, fthelp: dict[str, str] | None = None, **kwargs):
|
||||||
|
"""
|
||||||
|
CLI Arguments - used to build subcommand parsers consistently.
|
||||||
|
:param fthelp: dict - fthelp per command - should be "freqtrade <command>": help_text
|
||||||
|
If not provided or not found, 'help' from kwargs is used instead.
|
||||||
|
"""
|
||||||
self.cli = args
|
self.cli = args
|
||||||
|
self.fthelp = fthelp
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
|
|
||||||
@@ -422,6 +428,14 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
),
|
),
|
||||||
"candle_types": Arg(
|
"candle_types": Arg(
|
||||||
"--candle-types",
|
"--candle-types",
|
||||||
|
fthelp={
|
||||||
|
"freqtrade download-data": (
|
||||||
|
"Select candle type to download. "
|
||||||
|
"Defaults to the necessary candles for the selected trading mode "
|
||||||
|
"(e.g. 'spot' or ('futures', 'funding_rate' and 'mark') for futures)."
|
||||||
|
),
|
||||||
|
"_": "Select candle type to convert. Defaults to all available types.",
|
||||||
|
},
|
||||||
help="Select candle type to convert. Defaults to all available types.",
|
help="Select candle type to convert. Defaults to all available types.",
|
||||||
choices=[c.value for c in CandleType],
|
choices=[c.value for c in CandleType],
|
||||||
nargs="+",
|
nargs="+",
|
||||||
|
|||||||
Reference in New Issue
Block a user