Skip to content

Commit 69248f1

Browse files
Add error for missing command (#216)
1 parent 2ca2b5b commit 69248f1

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

liskov/src/icon4py/liskov/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import click
1717

1818
from icon4py.common.logger import setup_logger
19+
from icon4py.liskov.external.exceptions import MissingCommandError
1920
from icon4py.liskov.pipeline.collection import (
2021
load_gt4py_stencils,
2122
parse_fortran_file,
@@ -31,7 +32,7 @@
3132
def main(ctx):
3233
"""Command line interface for interacting with the ICON-Liskov DSL Preprocessor."""
3334
if ctx.invoked_subcommand is None:
34-
click.echo(
35+
raise MissingCommandError(
3536
"Need to choose one of the following commands:\nintegrate\nserialise"
3637
)
3738

liskov/src/icon4py/liskov/external/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ class UnknownStencilError(Exception):
2222

2323
class IncompatibleFieldError(Exception):
2424
pass
25+
26+
27+
class MissingCommandError(Exception):
28+
pass

liskov/tests/test_cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pytest
1717

1818
from icon4py.liskov.cli import main
19+
from icon4py.liskov.external.exceptions import MissingCommandError
1920
from icon4py.testutils.liskov_fortran_samples import (
2021
CONSECUTIVE_STENCIL,
2122
FREE_FORM_STENCIL,
@@ -67,3 +68,10 @@ def test_cli(make_f90_tmpfile, cli, outfile, file_name, file_content, cmd, cmd_f
6768
args = [cmd, *cmd_flags, fpath, outfile]
6869
result = cli.invoke(main, args)
6970
assert result.exit_code == 0
71+
72+
73+
def test_cli_missing_command(cli):
74+
args = []
75+
result = cli.invoke(main, args)
76+
assert result.exit_code == 1
77+
assert isinstance(result.exception, MissingCommandError)

0 commit comments

Comments
 (0)