Skip to content

Commit

Permalink
Add --value-type option to the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
jasujm committed May 8, 2020
1 parent 01d1554 commit 9c04594
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/enumecg/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
type=click.Choice(PRIMARY_TYPE_CHOICES),
help="Primary enumeration type",
)
@click.option("--value-type", help="Enumerator value type")
@click.argument("file", type=click.File())
def cli(file=sys.stdin, documentation=None, primary_type=None):
def cli(file=sys.stdin, documentation=None, primary_type=None, value_type=None):
"""Generate C++ boilerplate for an Enhanced Enum definition
This executable is a part of the Enhanced Enum library. It is used
Expand All @@ -46,4 +47,11 @@ def cli(file=sys.stdin, documentation=None, primary_type=None):
"""
enum = yaml.safe_load(file)
click.echo(generate(enum, documentation=documentation, primary_type=primary_type))
click.echo(
generate(
enum,
documentation=documentation,
primary_type=primary_type,
value_type=value_type,
)
)
7 changes: 7 additions & 0 deletions python/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ def test_cli_should_have_primeray_type_option(
result.output
== generate(status_definition_dict, primary_type=primary_type) + "\n"
)


def test_cli_should_have_value_type_option(
cli_runner, enum_file, status_definition_dict
):
result = cli_runner.invoke(cli, ["--value-type", "MyType", str(enum_file)])
assert result.output == generate(status_definition_dict, value_type="MyType") + "\n"

0 comments on commit 9c04594

Please sign in to comment.