-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently the executable is a stub, and this commit merely sets up the necessary modules, tests and documentation. The purpose is to allow most of the functionality of the library (config options etc.) to from command line.
- Loading branch information
Showing
9 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
typename: Status | ||
members: | ||
- name: INITIALIZING | ||
value: initializing | ||
- name: WAITING_FOR_INPUT | ||
value: waitingForInput | ||
- name: BUSY | ||
value: busy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .cli import cli | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
EnumECG command line interface | ||
.............................. | ||
Contains the command line interface to EnumECG. The entry point is | ||
:func:`cli()`. | ||
""" | ||
|
||
import click | ||
import yaml | ||
|
||
from . import generate | ||
|
||
@click.command() | ||
@click.argument("file", type=click.File()) | ||
def cli(file): | ||
"""Generate C++ boilerplate for an Enhanced Enum definition | ||
This executable is a part of the Enhanced Enum library. It is used | ||
to generate the necessary C++ boilerplate to make an enumeration | ||
type work with the library. | ||
For a full discussion of the purpose of the library, and a | ||
detailed description of the code generation process, see: | ||
https://enhanced-enum.readthedocs.io/en/latest/ | ||
""" | ||
enum = yaml.safe_load(file) | ||
click.echo(generate(enum)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import yaml | ||
import pytest | ||
|
||
from click.testing import CliRunner | ||
|
||
from enumecg import generate | ||
from enumecg.cli import cli | ||
|
||
@pytest.fixture | ||
def cli_runner(): | ||
"""Return CliRunner() to invoke enumecg CLI""" | ||
return CliRunner() | ||
|
||
@pytest.fixture | ||
def enum_file(tmpdir, status_definition_dict): | ||
"""Return path to an YAML file containing serialized :const:`conftest.STATUS_DEFINITION_DICT`""" | ||
p = tmpdir.join("enum.yaml") | ||
with open(p, "w") as f: | ||
yaml.dump(status_definition_dict, f) | ||
return p | ||
|
||
def test_cli_should_generate_enum_definition_from_file(cli_runner, enum_file, status_definition): | ||
result = cli_runner.invoke(cli, [str(enum_file)]) | ||
assert result.output == generate(status_definition) + "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ jinja2>=2.10 | |
regex | ||
inflect>=3.0 | ||
docstring-parser>=0.6 | ||
PyYAML>=5.3 | ||
click>=7.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters