Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fixes arguments and help message #6

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/openapi_to_asciidoc/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,27 @@

import argparse
import json
import sys

from openapi_to_asciidoc.objects import OpenApi, OpenApiSchema


def get_arguments():
"""
Parses command line arguments
"""

usage = """
Usage:

Use stdin and stdout:
cat openapi.json | openapi_to_asciidoc.py -t openapi.j2

Use specific files for input and output:
openapi_to_asciidoc.py -j openapi.json -t openapi.j2 -o openapi.adoc
"""
parser = argparse.ArgumentParser(epilog=usage, formatter_class=argparse.RawDescriptionHelpFormatter)
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)

parser.add_argument(
"-j",
"--json",
help="OpenAPI JSON Specification File (default: stdin)",
help="OpenAPI JSON Specification File (default: openapi.json)",
type=argparse.FileType("r"),
default=sys.stdin,
default="openapi.json",
)
parser.add_argument(
"-o",
"--output",
nargs="?",
help="Where to output result (default: stdout)",
help="Where to output result (default: openapi.adoc)",
type=argparse.FileType("w"),
default=sys.stdout,
default="openapi.adoc",
)

return parser.parse_args()
Expand Down
Loading