clan: add dynamic completions to clan backups
providers
This commit is contained in:
parent
b4699cd8a3
commit
c9038ad0b3
|
@ -2,7 +2,11 @@ import argparse
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from ..completions import add_dynamic_completer, complete_machines
|
from ..completions import (
|
||||||
|
add_dynamic_completer,
|
||||||
|
complete_backup_providers_for_machine,
|
||||||
|
complete_machines,
|
||||||
|
)
|
||||||
from ..errors import ClanError
|
from ..errors import ClanError
|
||||||
from ..machines.machines import Machine
|
from ..machines.machines import Machine
|
||||||
|
|
||||||
|
@ -46,5 +50,8 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
)
|
)
|
||||||
add_dynamic_completer(machines_parser, complete_machines)
|
add_dynamic_completer(machines_parser, complete_machines)
|
||||||
|
|
||||||
parser.add_argument("--provider", type=str, help="backup provider to use")
|
provider_action = parser.add_argument(
|
||||||
|
"--provider", type=str, help="backup provider to use"
|
||||||
|
)
|
||||||
|
add_dynamic_completer(provider_action, complete_backup_providers_for_machine)
|
||||||
parser.set_defaults(func=create_command)
|
parser.set_defaults(func=create_command)
|
||||||
|
|
|
@ -3,7 +3,11 @@ import json
|
||||||
import subprocess
|
import subprocess
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from ..completions import add_dynamic_completer, complete_machines
|
from ..completions import (
|
||||||
|
add_dynamic_completer,
|
||||||
|
complete_backup_providers_for_machine,
|
||||||
|
complete_machines,
|
||||||
|
)
|
||||||
from ..errors import ClanError
|
from ..errors import ClanError
|
||||||
from ..machines.machines import Machine
|
from ..machines.machines import Machine
|
||||||
|
|
||||||
|
@ -62,5 +66,8 @@ def register_list_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
"machine", type=str, help="machine in the flake to show backups of"
|
"machine", type=str, help="machine in the flake to show backups of"
|
||||||
)
|
)
|
||||||
add_dynamic_completer(machines_parser, complete_machines)
|
add_dynamic_completer(machines_parser, complete_machines)
|
||||||
parser.add_argument("--provider", type=str, help="backup provider to filter by")
|
provider_action = parser.add_argument(
|
||||||
|
"--provider", type=str, help="backup provider to filter by"
|
||||||
|
)
|
||||||
|
add_dynamic_completer(provider_action, complete_backup_providers_for_machine)
|
||||||
parser.set_defaults(func=list_command)
|
parser.set_defaults(func=list_command)
|
||||||
|
|
|
@ -2,6 +2,11 @@ import argparse
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from ..completions import (
|
||||||
|
add_dynamic_completer,
|
||||||
|
complete_backup_providers_for_machine,
|
||||||
|
complete_machines,
|
||||||
|
)
|
||||||
from ..errors import ClanError
|
from ..errors import ClanError
|
||||||
from ..machines.machines import Machine
|
from ..machines.machines import Machine
|
||||||
|
|
||||||
|
@ -74,10 +79,14 @@ def restore_command(args: argparse.Namespace) -> None:
|
||||||
|
|
||||||
|
|
||||||
def register_restore_parser(parser: argparse.ArgumentParser) -> None:
|
def register_restore_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
parser.add_argument(
|
machine_action = parser.add_argument(
|
||||||
"machine", type=str, help="machine in the flake to create backups of"
|
"machine", type=str, help="machine in the flake to create backups of"
|
||||||
)
|
)
|
||||||
parser.add_argument("provider", type=str, help="backup provider to use")
|
add_dynamic_completer(machine_action, complete_machines)
|
||||||
|
provider_action = parser.add_argument(
|
||||||
|
"provider", type=str, help="backup provider to use"
|
||||||
|
)
|
||||||
|
add_dynamic_completer(provider_action, complete_backup_providers_for_machine)
|
||||||
parser.add_argument("name", type=str, help="Name of the backup to restore")
|
parser.add_argument("name", type=str, help="Name of the backup to restore")
|
||||||
parser.add_argument("--service", type=str, help="name of the service to restore")
|
parser.add_argument("--service", type=str, help="name of the service to restore")
|
||||||
parser.set_defaults(func=restore_command)
|
parser.set_defaults(func=restore_command)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user