Use vlogging's main_fallback name feature in snippets.

This commit is contained in:
voussoir 2021-01-28 16:52:23 -08:00
parent eadffcfdd2
commit f5df7b4dda
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
3 changed files with 11 additions and 11 deletions

View file

@ -5,7 +5,7 @@ import sys
from voussoirkit import vlogging from voussoirkit import vlogging
log = vlogging.getLogger(__name__) log = vlogging.getLogger(__name__, '$1')
def $1_argparse(args): def $1_argparse(args):
return $1() return $1()

View file

@ -5,10 +5,10 @@ import sys
from voussoirkit import vlogging from voussoirkit import vlogging
log = vlogging.getLogger(__name__) log = vlogging.getLogger(__name__, '$1')
def $1_argparse(args): def $2_argparse(args):
return $1() return $2()
def main(argv): def main(argv):
argv = vlogging.set_level_by_argv(log, argv) argv = vlogging.set_level_by_argv(log, argv)
@ -16,12 +16,12 @@ def main(argv):
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers() subparsers = parser.add_subparsers()
p_$1 = subparsers.add_parser('$1') p_$2 = subparsers.add_parser('$2')
p_$1.add_argument('required_positional') p_$2.add_argument('required_positional')
p_$1.add_argument('optional_positional', nargs='?', default=None) p_$2.add_argument('optional_positional', nargs='?', default=None)
p_$1.add_argument('-k', '--kwarg', dest='kwarg', default=None) p_$2.add_argument('-k', '--kwarg', dest='kwarg', default=None)
p_$1.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true') p_$2.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
p_$1.set_defaults(func=$1_argparse) p_$2.set_defaults(func=$2_argparse)
args = parser.parse_args(argv) args = parser.parse_args(argv)
return args.func(args) return args.func(args)

View file

@ -2,7 +2,7 @@
<content><![CDATA[ <content><![CDATA[
from voussoirkit import vlogging from voussoirkit import vlogging
log = vlogging.getLogger(__name__) log = vlogging.getLogger(__name__, '$1')
def main(argv): def main(argv):
argv = vlogging.set_level_by_argv(log, argv) argv = vlogging.set_level_by_argv(log, argv)