clan_cli: flake_name -> flake_dir
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
import argparse
|
||||
|
||||
from .create import register_create_parser
|
||||
from .list_flakes import register_list_parser
|
||||
|
||||
|
||||
# takes a (sub)parser and configures it
|
||||
@@ -15,6 +14,3 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
|
||||
)
|
||||
create_parser = subparser.add_parser("create", help="Create a clan flake")
|
||||
register_create_parser(create_parser)
|
||||
|
||||
list_parser = subparser.add_parser("list", help="List clan flakes")
|
||||
register_list_parser(list_parser)
|
||||
|
||||
@@ -7,7 +7,6 @@ from pydantic import AnyUrl
|
||||
from pydantic.tools import parse_obj_as
|
||||
|
||||
from ..async_cmd import CmdOut, run, runforcli
|
||||
from ..dirs import clan_flakes_dir
|
||||
from ..errors import ClanError
|
||||
from ..nix import nix_command, nix_shell
|
||||
|
||||
@@ -63,22 +62,16 @@ async def create_flake(directory: Path, url: AnyUrl) -> Dict[str, CmdOut]:
|
||||
|
||||
|
||||
def create_flake_command(args: argparse.Namespace) -> None:
|
||||
flake_dir = clan_flakes_dir() / args.name
|
||||
runforcli(create_flake, flake_dir, args.url)
|
||||
runforcli(create_flake, args.path, args.url)
|
||||
|
||||
|
||||
# takes a (sub)parser and configures it
|
||||
def register_create_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument(
|
||||
"name",
|
||||
type=str,
|
||||
help="name for the flake",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--url",
|
||||
type=str,
|
||||
help="url for the flake",
|
||||
default=DEFAULT_URL,
|
||||
)
|
||||
# parser.add_argument("name", type=str, help="name of the flake")
|
||||
parser.add_argument("path", type=Path, help="Path to the flake", default=Path("."))
|
||||
parser.set_defaults(func=create_flake_command)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
|
||||
from ..dirs import clan_flakes_dir
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def list_flakes() -> list[str]:
|
||||
path = clan_flakes_dir()
|
||||
log.debug(f"Listing machines in {path}")
|
||||
if not path.exists():
|
||||
return []
|
||||
objs: list[str] = []
|
||||
for f in os.listdir(path):
|
||||
objs.append(f)
|
||||
return objs
|
||||
|
||||
|
||||
def list_command(args: argparse.Namespace) -> None:
|
||||
for flake in list_flakes():
|
||||
print(flake)
|
||||
|
||||
|
||||
def register_list_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.set_defaults(func=list_command)
|
||||
Reference in New Issue
Block a user