Improve arg parsing in dump-swagger

pull/977/head
Richard van der Hoff 7 years ago
parent 2a48bc5847
commit 986c9d99a0

@ -19,7 +19,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import errno
import json
import logging
@ -37,16 +37,24 @@ sys.path.insert(0, templating_dir)
from matrix_templates import units
if len(sys.argv) > 3:
sys.stderr.write("usage: %s [output_file] [client_release_label]\n" % (sys.argv[0],))
sys.exit(1)
if len(sys.argv) > 1:
output_file = os.path.abspath(sys.argv[1])
else:
output_file = os.path.join(scripts_dir, "swagger", "api-docs.json")
release_label = sys.argv[2] if len(sys.argv) > 2 else "unstable"
parser = argparse.ArgumentParser(
"dump-swagger.py - assemble the Swagger specs into a single JSON file"
)
parser.add_argument(
"--client_release", "-c", metavar="LABEL",
default="unstable",
help="""The client-server release version to gneerate for. Default:
%(default)s""",
)
parser.add_argument(
"-o", "--output",
default=os.path.join(scripts_dir, "swagger", "api-docs.json"),
help="File to write the output to. Default: %(default)s"
)
args = parser.parse_args()
output_file = os.path.abspath(args.output)
release_label = args.client_release
major_version = release_label
match = re.match("^(r\d+)(\.\d+)*$", major_version)

Loading…
Cancel
Save