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

Compatibility with argparse-manpage #305

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 14 additions & 5 deletions cmakelang/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,26 @@ def setup_argparser(arg_parser):
arg_parser.add_argument('infilepaths', nargs='*')


def get_argparser():
argparser = argparse.ArgumentParser(
prog='cmake-annotate',
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE_STRING)

setattr(argparser, 'man_short_description', __doc__.strip().splitlines()[0])

setup_argparser(argparser)
return argparser


def main():
"""Parse arguments, open files, start work."""

# set up main logger, which logs everything. We'll leave this one logging
# to the console
logging.basicConfig(level=logging.INFO)
arg_parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE_STRING)
setup_argparser(arg_parser)
arg_parser = get_argparser()
args = arg_parser.parse_args()

assert (len(args.infilepaths) == 1
Expand Down
21 changes: 21 additions & 0 deletions cmakelang/contrib/signature_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,26 @@
"46OOj1B85tUs1+f6wCuX4SyIVww5aA==",
"=4ykw"
]
},
{
"template": "individual",
"version": "1.0",
"name": "Ian Campbell",
"email": "ijc@debian.org",
"signature": [
"iQIzBAABCAAdFiEE7fn8DiT6MgcCyDswKi4ln2laRsYFAmO6oWoACgkQKi4ln2la",
"RsZGOw//Qhm+ZscRad8D23eqs0fbWYFSOIZGzlPWnu9RiRcmmSOvuPi2AwZM9pUV",
"aTi8Fuh3Y8wx1OjWw7Px8TfWDwLvV52cCTt7G7RVIDxUhGyPuEttYgwK2ADc3bYz",
"Qe3gns/CeCWFQCbb1pQzd5pTc2Ocj0LvEpZOt16Uqi+vDYduhstZ38NneqRzC8S6",
"54UQXSKfEmm8SbsxMBxQIVErxE2Op8z2eSjy1yZfwVdiJifLDzJ6fDQpQt3tKZxC",
"JYxbHLeii8H6MIuV/XR2Cr7cyMkOCUYUgbY4drqMA3bbUdrEASAbAazMNCMAmouh",
"FBP3NWfv0hGae7azfBetPIpibo5xXc4Hg3EkxHK8UeZ9swZtLXZhSwwglDFr13CE",
"57Lq/Kjhd/2zr6LEtUFd1HPx66qFDdCnrXHckoWqHr4fMEiBNXYV3JoPsBs/n2ae",
"VD03NxxMPzgoTqmqikZBkURnFT0aogzEQjffYIde+xeyLFKWTg9ibRaugizOsPV/",
"Q0D9JQ0qXkn1JhJWCmE2r0TDY2Z06ZpB+dnBhNfepgXb/YBmCYDk0lhoocjqPt6Q",
"BG1MRlycaZkYWb01TPbCvV1n1Ecp/UzQlG9tzaiUDtL5kGUixKT1hBje6grxw4+C",
"jW75xhPbMkGTjEWg9ugrwmj0gkGBjx5cC8w7s4UBPCv5XQQAjXQ=",
"=AXfC"
]
}
]
13 changes: 10 additions & 3 deletions cmakelang/format/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,22 @@ def onefile_main(infile_path, args, argparse_dict):
shutil.move(tempfile_path, infile_path)


def inner_main():
"""Parse arguments, open files, start work."""

def get_argparser():
arg_parser = argparse.ArgumentParser(
prog='cmake-format',
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE_STRING)

setattr(arg_parser, 'man_short_description', __doc__.strip().splitlines()[0])

setup_argparser(arg_parser)
return arg_parser

def inner_main():
"""Parse arguments, open files, start work."""

arg_parser = get_argparser()
try:
import argcomplete
argcomplete.autocomplete(arg_parser)
Expand Down
23 changes: 15 additions & 8 deletions cmakelang/genparsers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""
Parse cmake listfiles, find function and macro declarations, and generate
parsers for them.
Parse cmake listfiles, find function and macro declarations, and generate parsers for them.
"""
from __future__ import print_function, unicode_literals

Expand Down Expand Up @@ -214,6 +213,19 @@ def setup_argparse(argparser):
argparser.add_argument('infilepaths', nargs='*')


def get_argparser():
argparser = argparse.ArgumentParser(
prog='cmake-genparsers',
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE_STRING)

setattr(argparser, 'man_short_description', __doc__.strip().splitlines()[0])

setup_argparse(argparser)
return argparser


USAGE_STRING = """
cmake-genparsers [-h] [-o OUTFILE_PATH] infilepath [infilepath ...]
"""
Expand All @@ -223,12 +235,7 @@ def main():
"""Parse arguments, open files, start work."""
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")

argparser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE_STRING)

setup_argparse(argparser)
argparser = get_argparser()
args = argparser.parse_args()
logging.getLogger().setLevel(getattr(logging, args.log_level.upper()))

Expand Down
19 changes: 13 additions & 6 deletions cmakelang/lint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,23 @@ def setup_argparse(argparser):
"""


def inner_main():
"""Parse arguments, open files, start work."""
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")

argparser = argparse.ArgumentParser(
def get_argparser():
arg_parser = argparse.ArgumentParser(
prog='cmake-lint',
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE_STRING)

setup_argparse(argparser)
setattr(arg_parser, 'man_short_description', __doc__.strip().splitlines()[0])

setup_argparse(arg_parser)
return arg_parser

def inner_main():
"""Parse arguments, open files, start work."""
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")

argparser = get_argparser()
try:
import argcomplete
argcomplete.autocomplete(argparser)
Expand Down