Skip to content

Commit 196aed4

Browse files
Add links to installer and CLI root (#739)
1 parent 17f5d95 commit 196aed4

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

src/dipdup/cli.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,28 @@
2020
import asyncclick as click
2121

2222
from dipdup import __version__
23+
from dipdup.install import EPILOG
24+
from dipdup.install import WELCOME_ASCII
2325
from dipdup.performance import metrics
2426
from dipdup.report import REPORTS_PATH
2527
from dipdup.report import ReportHeader
2628
from dipdup.report import save_report
2729
from dipdup.sys import set_up_process
2830

31+
_click_wrap_text = click.formatting.wrap_text
32+
33+
34+
def _wrap_text(text: str, *a: Any, **kw: Any) -> str:
35+
# NOTE: WELCOME_ASCII and EPILOG
36+
if text.startswith((' ')):
37+
return text
38+
if text.startswith(('\0\n')):
39+
return text[2:]
40+
return _click_wrap_text(text, *a, **kw)
41+
42+
43+
click.formatting.wrap_text = _wrap_text
44+
2945
ROOT_CONFIG = 'dipdup.yaml'
3046
CONFIG_RE = r'dipdup.*\.ya?ml'
3147

@@ -130,7 +146,11 @@ async def _check_version() -> None:
130146
_logger.info('Set `skip_version_check` flag in config to hide this message.')
131147

132148

133-
@click.group(context_settings={'max_content_width': 120})
149+
@click.group(
150+
context_settings={'max_content_width': 120},
151+
help=WELCOME_ASCII,
152+
epilog=EPILOG,
153+
)
134154
@click.version_option(__version__)
135155
@click.option(
136156
'--config',
@@ -153,12 +173,6 @@ async def _check_version() -> None:
153173
@click.pass_context
154174
@_cli_wrapper
155175
async def cli(ctx: click.Context, config: list[str], env_file: list[str]) -> None:
156-
"""Manage and run DipDup indexers.
157-
158-
Documentation: https://docs.dipdup.io
159-
160-
Issues: https://github.com/dipdup-io/dipdup/issues
161-
"""
162176
# NOTE: Workaround for help pages. First argument check is for the test runner.
163177
args = sys.argv[1:] if sys.argv else ['--help']
164178
if '--help' in args or args in (['config'], ['hasura'], ['schema']) or args[0] in ('self', 'report'):
@@ -631,6 +645,7 @@ async def self_update(
631645
@click.pass_context
632646
@_cli_wrapper
633647
async def report(ctx: click.Context) -> None:
648+
"""List and manage reports."""
634649
if ctx.invoked_subcommand:
635650
return
636651

@@ -643,7 +658,7 @@ async def report(ctx: click.Context) -> None:
643658
from ruamel.yaml import YAML
644659

645660
event = YAML(typ='base').load(path)
646-
row = [event.get(key, 'none') for key in header]
661+
row = [event.get(key, 'none')[:80] for key in header]
647662
rows.append(row)
648663

649664
rows.sort(key=lambda row: str(row[3]))

src/dipdup/install.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@
2929
'pyenv',
3030
)
3131

32-
WELCOME_ASCII = r"""
32+
WELCOME_ASCII = """\0
3333
____ _ ____
3434
/ __ \ (_)____ / __ \ __ __ ____
35-
/ / / // // __ \ / / / // / / // __ \
35+
/ / / // // __ \ / / / // / / // __ \\
3636
/ /_/ // // /_/ // /_/ // /_/ // /_/ /
3737
/_____//_// .___//_____/ \__,_// .___/
3838
/_/ /_/
3939
"""
40+
EPILOG = """\0
41+
Documentation: https://docs.dipdup.io
42+
GitHub: https://github.com/dipdup-io/dipdup
43+
Discord: https://discord.gg/NbANhqCJHA
44+
"""
4045

4146

4247
class Colors:
@@ -79,6 +84,7 @@ def __init__(self, quiet: bool = False) -> None:
7984
def refresh(self) -> None:
8085
if not self._quiet and not self._commands:
8186
print(WELCOME_ASCII)
87+
print(EPILOG)
8288
print()
8389
print(_tab('OS:') + self._os)
8490
print(_tab('Arch:') + self._arch)
@@ -103,9 +109,6 @@ def refresh_pipx(self) -> None:
103109
self._quiet or print(_tab('pipx packages:') + ', '.join(self._pipx_packages) + '\n')
104110

105111
def check(self) -> None:
106-
# if not sys.version.startswith('3.11'):
107-
# fail('DipDup requires Python 3.11')
108-
109112
# NOTE: Show warning if user is root
110113
if os.geteuid() == 0:
111114
echo('WARNING: Running as root, this is not generally recommended', Colors.YELLOW)

0 commit comments

Comments
 (0)