clan-cli: make jsonschema optional
This commit is contained in:
parent
7b2e9cc46e
commit
48a5f64be6
@ -1,15 +1,21 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from . import admin, config, secrets, update
|
from . import admin, secrets, update
|
||||||
from .errors import ClanError
|
from .errors import ClanError
|
||||||
from .ssh import cli as ssh_cli
|
from .ssh import cli as ssh_cli
|
||||||
|
|
||||||
has_argcomplete = True
|
argcomplete = None
|
||||||
try:
|
try:
|
||||||
import argcomplete
|
import argcomplete
|
||||||
except ImportError:
|
except ImportError:
|
||||||
has_argcomplete = False
|
pass
|
||||||
|
|
||||||
|
config = None
|
||||||
|
try:
|
||||||
|
from . import config
|
||||||
|
except ImportError: # jsonschema not installed
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# this will be the entrypoint under /bin/clan (see pyproject.toml config)
|
# this will be the entrypoint under /bin/clan (see pyproject.toml config)
|
||||||
@ -20,6 +26,7 @@ def main() -> None:
|
|||||||
parser_admin = subparsers.add_parser("admin", help="administrate a clan")
|
parser_admin = subparsers.add_parser("admin", help="administrate a clan")
|
||||||
admin.register_parser(parser_admin)
|
admin.register_parser(parser_admin)
|
||||||
|
|
||||||
|
if config:
|
||||||
parser_config = subparsers.add_parser("config", help="set nixos configuration")
|
parser_config = subparsers.add_parser("config", help="set nixos configuration")
|
||||||
config.register_parser(parser_config)
|
config.register_parser(parser_config)
|
||||||
|
|
||||||
@ -34,7 +41,7 @@ def main() -> None:
|
|||||||
)
|
)
|
||||||
update.register_parser(parser_update)
|
update.register_parser(parser_update)
|
||||||
|
|
||||||
if has_argcomplete:
|
if argcomplete:
|
||||||
argcomplete.autocomplete(parser)
|
argcomplete.autocomplete(parser)
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user