|
|
@ -17,6 +17,15 @@ class Substitute:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import argcomplete
|
|
|
|
import argcomplete
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
# argcomplete 3+
|
|
|
|
|
|
|
|
# see: https://github.com/kislyuk/argcomplete/commit/bd781cb08512b94966312377186ebc5550f46ae0
|
|
|
|
|
|
|
|
from argcomplete.finders import (
|
|
|
|
|
|
|
|
CompletionFinder,
|
|
|
|
|
|
|
|
default_validator,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
|
|
|
# argcomplete <3
|
|
|
|
from argcomplete import (
|
|
|
|
from argcomplete import (
|
|
|
|
CompletionFinder,
|
|
|
|
CompletionFinder,
|
|
|
|
default_validator,
|
|
|
|
default_validator,
|
|
|
@ -72,6 +81,12 @@ class CompType(enum.Enum):
|
|
|
|
def register_safe_action(action_type: t.Type[argparse.Action]) -> None:
|
|
|
|
def register_safe_action(action_type: t.Type[argparse.Action]) -> None:
|
|
|
|
"""Register the given action as a safe action for argcomplete to use during completion if it is not already registered."""
|
|
|
|
"""Register the given action as a safe action for argcomplete to use during completion if it is not already registered."""
|
|
|
|
if argcomplete and action_type not in argcomplete.safe_actions:
|
|
|
|
if argcomplete and action_type not in argcomplete.safe_actions:
|
|
|
|
|
|
|
|
if isinstance(argcomplete.safe_actions, set):
|
|
|
|
|
|
|
|
# argcomplete 3+
|
|
|
|
|
|
|
|
# see: https://github.com/kislyuk/argcomplete/commit/bd781cb08512b94966312377186ebc5550f46ae0
|
|
|
|
|
|
|
|
argcomplete.safe_actions.add(action_type)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# argcomplete <3
|
|
|
|
argcomplete.safe_actions += (action_type,)
|
|
|
|
argcomplete.safe_actions += (action_type,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|