Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sisl/_core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
list_index_le,
)
from sisl._internal import set_module
from sisl._lib._argparse import SislHelpFormatter
from sisl._math_small import cross3, is_ascending, xyz_to_spherical_cos_phi
from sisl._namedindex import NamedIndex
from sisl.messages import SislError, deprecate_argument, deprecation, info, warn
Expand Down Expand Up @@ -4783,7 +4784,7 @@ def sgeom(geometry=None, argv=None, ret_geometry=False):

p = argparse.ArgumentParser(
exe,
formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=SislHelpFormatter,
description=description,
)

Expand Down
3 changes: 2 additions & 1 deletion src/sisl/_core/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from sisl._dispatcher import AbstractDispatch, ClassDispatcher, TypeDispatcher
from sisl._help import dtype_complex_to_real, wrap_filterwarnings
from sisl._internal import set_module
from sisl._lib._argparse import SislHelpFormatter
from sisl.messages import deprecate_argument, deprecation
from sisl.shape import Shape
from sisl.utils import (
Expand Down Expand Up @@ -1747,7 +1748,7 @@ def sgrid(grid=None, argv=None, ret_grid=False):

p = argparse.ArgumentParser(
exe,
formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=SislHelpFormatter,
description=description,
)

Expand Down
11 changes: 11 additions & 0 deletions src/sisl/_lib/_argparse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
try:
from rich_argparse import RichHelpFormatter

SislHelpFormatter = RichHelpFormatter
except ImportError:
import argparse

SislHelpFormatter = argparse.RawDescriptionHelpFormatter
4 changes: 3 additions & 1 deletion src/sisl/utils/_sisl_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"""
import argparse

from sisl._lib._argparse import SislHelpFormatter

__all__ = ["sisl_cmd"]


Expand Down Expand Up @@ -99,7 +101,7 @@ def sisl_cmd(argv=None, sile=None):

p = argparse.ArgumentParser(
exe,
formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=SislHelpFormatter,
description=description,
conflict_handler="resolve",
)
Expand Down
8 changes: 6 additions & 2 deletions src/sisl_toolbox/cli/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from collections.abc import Callable
from pathlib import Path

from sisl._lib._argparse import SislHelpFormatter


class SToolBoxCLI:
"""Run the CLI `stoolbox`"""
Expand Down Expand Up @@ -47,7 +49,9 @@ def __call__(self, argv=None):
# Create command-line
cmd = Path(sys.argv[0])
p = argparse.ArgumentParser(
f"{cmd.name}", description="Specific toolboxes to aid sisl users"
f"{cmd.name}",
description="Specific toolboxes to aid sisl users",
formatter_class=SislHelpFormatter,
)

info = {
Expand All @@ -64,7 +68,7 @@ def __call__(self, argv=None):
subp = p.add_subparsers(**info)

for cmd in self._cmds:
cmd(subp)
cmd(subp, parser_kwargs=dict(formatter_class=p.formatter_class))

args = p.parse_args(argv)
args.runner(args)
Expand Down
6 changes: 3 additions & 3 deletions src/sisl_toolbox/siesta/atom/_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def next_rc(ir, ic, nrows, ncols):
return fig, axs


def atom_plot_cli(subp=None):
def atom_plot_cli(subp=None, parser_kwargs={}):
"""Run plotting command for the output of atom"""

is_sub = not subp is None
Expand All @@ -812,11 +812,11 @@ def atom_plot_cli(subp=None):
if is_sub:
global _script
_script = f"{_script} atom-plot"
p = subp.add_parser("atom-plot", description=title, help=title)
p = subp.add_parser("atom-plot", description=title, help=title, **parser_kwargs)
else:
import argparse

p = argparse.ArgumentParser(title)
p = argparse.ArgumentParser(title, **parser_kwargs)

p.add_argument(
"--plot",
Expand Down
6 changes: 3 additions & 3 deletions src/sisl_toolbox/transiesta/poisson/fftpoisson_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,16 @@ def sl2idx(grid, sl):
return grid


def fftpoisson_fix_cli(subp=None):
def fftpoisson_fix_cli(subp=None, parser_kwargs={}):
is_sub = not subp is None

title = "FFT Poisson corrections for TranSiesta calculations for arbitrary number of electrodes."
if is_sub:
global _script
_script = f"{_script} ts-fft"
p = subp.add_parser("ts-fft", description=title, help=title)
p = subp.add_parser("ts-fft", description=title, help=title, **parser_kwargs)
else:
p = argp.ArgumentParser(title)
p = argp.ArgumentParser(title, **parser_kwargs)

tuning = p.add_argument_group(
"tuning", "Tuning fine details of the Poisson calculation."
Expand Down
Loading