Skip to content

Commit 0be85fd

Browse files
committed
CM-47493 - Make changes in CLI v3.0.0 after feedback
1 parent 6c70c21 commit 0be85fd

File tree

19 files changed

+209
-87
lines changed

19 files changed

+209
-87
lines changed

cycode/cli/app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Annotated, Optional
44

55
import typer
6+
from typer import rich_utils
67
from typer.completion import install_callback, show_callback
78

89
from cycode import __version__
@@ -18,11 +19,18 @@
1819
from cycode.cyclient.models import UserAgentOptionScheme
1920
from cycode.logger import set_logging_level
2021

22+
# By default, it uses dim style which is hard to read with the combination of color from RICH_HELP
23+
rich_utils.STYLE_ERRORS_SUGGESTION = 'bold'
24+
# By default, it uses blue color which is too dark for some terminals
25+
rich_utils.RICH_HELP = "Try [cyan]'{command_path} {help_option}'[/] for help."
26+
27+
2128
app = typer.Typer(
2229
pretty_exceptions_show_locals=False,
2330
pretty_exceptions_short=True,
2431
context_settings=CLI_CONTEXT_SETTINGS,
2532
rich_markup_mode='rich',
33+
no_args_is_help=True,
2634
add_completion=False, # we add it manually to control the rich help panel
2735
)
2836

cycode/cli/apps/ai_remediation/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from cycode.cli.apps.ai_remediation.ai_remediation_command import ai_remediation_command
44

5-
app = typer.Typer()
5+
app = typer.Typer(no_args_is_help=True)
66
app.command(name='ai-remediation', short_help='Get AI remediation (INTERNAL).', hidden=True)(ai_remediation_command)
77

88
# backward compatibility

cycode/cli/apps/auth/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
app = typer.Typer(
77
name='auth',
88
help='Authenticate your machine to associate the CLI with your Cycode account.',
9+
no_args_is_help=True,
910
)
1011
app.callback(invoke_without_command=True)(auth_command)
1112
app.command(name='check')(check_command)

cycode/cli/apps/configure/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from cycode.cli.apps.configure.configure_command import configure_command
44

5-
app = typer.Typer()
5+
app = typer.Typer(no_args_is_help=True)
66
app.command(name='configure', short_help='Initial command to configure your CLI client authentication.')(
77
configure_command
88
)

cycode/cli/apps/ignore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
from cycode.cli.apps.ignore.ignore_command import ignore_command
44

5-
app = typer.Typer()
5+
app = typer.Typer(no_args_is_help=True)
66
app.command(name='ignore', short_help='Ignores a specific value, path or rule ID.')(ignore_command)

cycode/cli/apps/report/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from cycode.cli.apps.report import sbom
44
from cycode.cli.apps.report.report_command import report_command
55

6-
app = typer.Typer(name='report')
6+
app = typer.Typer(name='report', no_args_is_help=True)
77
app.callback(short_help='Generate report. You`ll need to specify which report type to perform.')(report_command)
88
app.add_typer(sbom.app)

cycode/cli/apps/scan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from cycode.cli.apps.scan.repository.repository_command import repository_command
88
from cycode.cli.apps.scan.scan_command import scan_command, scan_command_result_callback
99

10-
app = typer.Typer(name='scan')
10+
app = typer.Typer(name='scan', no_args_is_help=True)
1111

1212
app.callback(
1313
short_help='Scan the content for Secrets, IaC, SCA, and SAST violations.',

cycode/cli/apps/status/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from cycode.cli.apps.status.status_command import status_command
44
from cycode.cli.apps.status.version_command import version_command
55

6-
app = typer.Typer()
6+
app = typer.Typer(no_args_is_help=True)
77
app.command(name='status', short_help='Show the CLI status and exit.')(status_command)
88
app.command(name='version', hidden=True, short_help='Alias to status command.')(version_command)

cycode/cli/cli_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ def __rich__(self) -> str:
9494
SeverityOption.INFO.value: ':blue_circle:',
9595
SeverityOption.LOW.value: ':yellow_circle:',
9696
SeverityOption.MEDIUM.value: ':orange_circle:',
97-
SeverityOption.HIGH.value: ':heavy_large_circle:',
98-
SeverityOption.CRITICAL.value: ':red_circle:',
97+
SeverityOption.HIGH.value: ':red_circle:',
98+
SeverityOption.CRITICAL.value: ':exclamation_mark:', # double_exclamation_mark is not red
9999
}

cycode/cli/printers/console_printer.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class ConsolePrinter:
2929
# overrides
3030
'table_sca': ScaTablePrinter,
3131
'text_sca': ScaTablePrinter,
32-
'rich_sca': ScaTablePrinter,
3332
}
3433

3534
def __init__(
@@ -42,12 +41,7 @@ def __init__(
4241
self.ctx = ctx
4342
self.console = console_override or console
4443
self.console_err = console_err_override or console_err
45-
46-
self.scan_type = self.ctx.obj.get('scan_type')
4744
self.output_type = output_type_override or self.ctx.obj.get('output')
48-
self.aggregation_report_url = self.ctx.obj.get('aggregation_report_url')
49-
50-
self.printer = self._get_scan_printer()
5145

5246
self.console_record = None
5347

@@ -61,7 +55,16 @@ def __init__(
6155
output_type_override='json' if self.export_type == 'json' else self.output_type,
6256
)
6357

64-
def _get_scan_printer(self) -> 'PrinterBase':
58+
@property
59+
def scan_type(self) -> str:
60+
return self.ctx.obj.get('scan_type')
61+
62+
@property
63+
def aggregation_report_url(self) -> str:
64+
return self.ctx.obj.get('aggregation_report_url')
65+
66+
@property
67+
def printer(self) -> 'PrinterBase':
6568
printer_class = self._AVAILABLE_PRINTERS.get(self.output_type)
6669

6770
composite_printer = self._AVAILABLE_PRINTERS.get(f'{self.output_type}_{self.scan_type}')

0 commit comments

Comments
 (0)