aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minit.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-05-13 10:36:58 -0400
committerXavier Claessens <xavier.claessens@collabora.com>2018-10-04 09:40:21 -0400
commit37067a53c4b3b99982ef8e1f431ba0c9302b66e8 (patch)
tree7d3ebbb24b45bf6cfdb2a76a4dcdabf8808a346c /mesonbuild/minit.py
parent5af2717e76015b47bfc2b11d4034099d9b62d978 (diff)
downloadmeson-37067a53c4b3b99982ef8e1f431ba0c9302b66e8.zip
meson-37067a53c4b3b99982ef8e1f431ba0c9302b66e8.tar.gz
meson-37067a53c4b3b99982ef8e1f431ba0c9302b66e8.tar.bz2
Use a single ArgumentParser for all subcommands
This has the adventage that "meson --help" shows a list of all commands, making them discoverable. This also reduce the manual parsing of arguments to the strict minimum needed for backward compatibility.
Diffstat (limited to 'mesonbuild/minit.py')
-rw-r--r--mesonbuild/minit.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py
index a66361f..394fe40 100644
--- a/mesonbuild/minit.py
+++ b/mesonbuild/minit.py
@@ -14,7 +14,7 @@
"""Code that creates simple startup projects."""
-import os, sys, argparse, re, shutil, subprocess
+import os, sys, re, shutil, subprocess
from glob import glob
from mesonbuild import mesonlib
from mesonbuild.environment import detect_ninja
@@ -425,8 +425,7 @@ def create_meson_build(options):
open('meson.build', 'w').write(content)
print('Generated meson.build file:\n\n' + content)
-def run(args):
- parser = argparse.ArgumentParser(prog='meson')
+def add_arguments(parser):
parser.add_argument("srcfiles", metavar="sourcefile", nargs="*",
help="source files. default: all recognized files in current directory")
parser.add_argument("-n", "--name", help="project name. default: name of current directory")
@@ -441,7 +440,8 @@ def run(args):
parser.add_argument('--type', default='executable',
choices=['executable', 'library'])
parser.add_argument('--version', default='0.1')
- options = parser.parse_args(args)
+
+def run(options):
if len(glob('*')) == 0:
autodetect_options(options, sample=True)
if not options.language: