Improve arg parsing in dump-swagger
This commit is contained in:
parent
2a48bc5847
commit
986c9d99a0
1 changed files with 18 additions and 10 deletions
|
@ -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(
|
||||||
|
"--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()
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
output_file = os.path.abspath(args.output)
|
||||||
output_file = os.path.abspath(sys.argv[1])
|
release_label = args.client_release
|
||||||
else:
|
|
||||||
output_file = os.path.join(scripts_dir, "swagger", "api-docs.json")
|
|
||||||
|
|
||||||
release_label = sys.argv[2] if len(sys.argv) > 2 else "unstable"
|
|
||||||
|
|
||||||
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…
Add table
Add a link
Reference in a new issue