cli/create: add interactive name method
This commit is contained in:
@@ -4,6 +4,7 @@ import logging
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from clan_lib.clan.create import CreateOptions, create_clan
|
from clan_lib.clan.create import CreateOptions, create_clan
|
||||||
|
from clan_lib.errors import ClanError
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -28,8 +29,8 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"path",
|
"path",
|
||||||
type=Path,
|
type=Path,
|
||||||
|
nargs="?",
|
||||||
help="Path where to write the clan template to",
|
help="Path where to write the clan template to",
|
||||||
default=Path(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -40,6 +41,15 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def create_flake_command(args: argparse.Namespace) -> None:
|
def create_flake_command(args: argparse.Namespace) -> None:
|
||||||
|
# Ask for a path interactively if none provided
|
||||||
|
if args.path is None:
|
||||||
|
user_input = input("Enter a name for the new clan: ").strip()
|
||||||
|
if not user_input:
|
||||||
|
msg = "Error: name is required."
|
||||||
|
raise ClanError(msg)
|
||||||
|
|
||||||
|
args.path = Path(user_input)
|
||||||
|
|
||||||
create_clan(
|
create_clan(
|
||||||
CreateOptions(
|
CreateOptions(
|
||||||
dest=args.path,
|
dest=args.path,
|
||||||
|
|||||||
Reference in New Issue
Block a user