mirror of https://github.com/borgbackup/borg.git
move toggle action to beginning of class so it can be reused
This commit is contained in:
parent
a40729f4f3
commit
a6f8436ceb
|
@ -35,6 +35,20 @@ from .remote import RepositoryServer, RemoteRepository
|
|||
has_lchflags = hasattr(os, 'lchflags')
|
||||
|
||||
|
||||
class ToggleAction(argparse.Action):
|
||||
"""argparse action to handle "toggle" flags easily
|
||||
|
||||
toggle flags are in the form of ``--foo``, ``--no-foo``.
|
||||
|
||||
the ``--no-foo`` argument still needs to be passed to the
|
||||
``add_argument()`` call, but it simplifies the ``--no``
|
||||
detection.
|
||||
"""
|
||||
def __call__(self, parser, ns, values, option):
|
||||
"""set the given flag to true unless ``--no`` is passed"""
|
||||
setattr(ns, self.dest, not option.startswith('--no-'))
|
||||
|
||||
|
||||
class Archiver:
|
||||
|
||||
def __init__(self, verbose=False):
|
||||
|
@ -764,19 +778,6 @@ class Archiver:
|
|||
See the output of the "borg help patterns" command for more help on exclude patterns.
|
||||
""")
|
||||
|
||||
class ToggleAction(argparse.Action):
|
||||
"""argparse action to handle "toggle" flags easily
|
||||
|
||||
toggle flags are in the form of ``--foo``, ``--no-foo``.
|
||||
|
||||
the ``--no-foo`` argument still needs to be passed to the
|
||||
``add_argument()`` call, but it simplifies the ``--no``
|
||||
detection.
|
||||
"""
|
||||
def __call__(self, parser, ns, values, option):
|
||||
"""set the given flag to true unless ``--no`` is passed"""
|
||||
setattr(ns, self.dest, not option.startswith('--no-'))
|
||||
|
||||
subparser = subparsers.add_parser('create', parents=[common_parser],
|
||||
description=self.do_create.__doc__,
|
||||
epilog=create_epilog,
|
||||
|
|
Loading…
Reference in New Issue