diff --git a/README.md b/README.md index d036e43..6755f9c 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,17 @@ pipenv install ## Usage -- Run `pipenv run python serialize_data.py` to generate JSON file named `endpoints_data.json`. Optionally, you can specify the path of the proposed endpoints docs using `--file-path` option like: +- Run `pipenv run python serialize_data.py` to generate JSON file named `endpoints_data.json`. However, you have to specify the path of the proposed endpoints docs as - ```pipenv run python serialize_data.py --file-path /pat/to/endpoints_data.json``` + ```pipenv run python serialize_data.py /path/to/proposed_endpoints.md``` + + You can also provide multiple files by using the regex shorthand as + + ```pipenv run python serialize_data.py *.md``` + + If files resides at different paths, then you may provide them as positional argument to it. For e.g + + ```pipenv run python serialize_data.py /path/to/some_file.md /path/to/another_file.md``` - Run `pipenv run python create_mock_endpoints.py` to generate `app.py` with all the code for the Mocked end points. diff --git a/src/serialize_data.py b/src/serialize_data.py index 138aa3f..804c7d2 100644 --- a/src/serialize_data.py +++ b/src/serialize_data.py @@ -99,15 +99,24 @@ def get_json_from_endpoints(lines): @click.command() -@click.option( - "--file-path", - default="proposed_endpoints.md", - help="Path for the proposed endpoints docs", +@click.argument( + "file_paths", + nargs=-1, + type=click.Path(exists=True), + required=True, ) -def generate_json_from_docs_file(file_path): - lines = None - with open(file_path, "r") as endpoint_file: - lines = endpoint_file.read() +def generate_json_from_docs_file(file_paths): + """ + FILE_PATHS: Path(s) to the proposed endpoints docs. This can have multiple file values like + + serialize_data.py proposed_endpoint.md api_endpoint.md + + serialize_data.py *.md + """ + lines = '' + for path in file_paths: + with open(path, "r") as endpoint_file: + lines += endpoint_file.read() json_data = get_json_from_endpoints(lines) with open("endpoints_data.json", "w") as json_file: