Improve arg parsing in dump-swagger

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

Loading…
Cancel
Save