Add ability to run subset of menus
This commit is contained in:
parent
55e75f3faf
commit
d9b0eabd8d
@ -45,6 +45,13 @@ async def cli_async() -> int:
|
|||||||
|
|
||||||
parser = ArgumentParser(description="Cook!")
|
parser = ArgumentParser(description="Cook!")
|
||||||
parser.add_argument("hostspec", type=str, help="Sous or group name")
|
parser.add_argument("hostspec", type=str, help="Sous or group name")
|
||||||
|
parser.add_argument(
|
||||||
|
"--menu",
|
||||||
|
"-m",
|
||||||
|
type=str,
|
||||||
|
help="Specify a comma-separated list of names of menu to cook. "
|
||||||
|
"If not specified, all menus will be cooked.",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--yes",
|
"--yes",
|
||||||
"-y",
|
"-y",
|
||||||
@ -64,7 +71,11 @@ async def cli_async() -> int:
|
|||||||
eprint("Don't appear to be in a head. STOP.")
|
eprint("Don't appear to be in a head. STOP.")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
head = Head.open(str(cdir))
|
menu_subset = None
|
||||||
|
if argp.menu:
|
||||||
|
menu_subset = argp.menu.split(",")
|
||||||
|
|
||||||
|
head = Head.open(str(cdir), menu_subset)
|
||||||
|
|
||||||
eprint(head.debug_info())
|
eprint(head.debug_info())
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class Head:
|
|||||||
self.pools = pools
|
self.pools = pools
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def open(directory: str):
|
def open(directory: str, menu_subset: Optional[List[str]] = None):
|
||||||
with open(path.join(directory, "scone.head.toml")) as head_toml:
|
with open(path.join(directory, "scone.head.toml")) as head_toml:
|
||||||
head_data = toml.load(head_toml)
|
head_data = toml.load(head_toml)
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class Head:
|
|||||||
|
|
||||||
head = Head(directory, recipe_loader, sous, groups, secret_access, pools)
|
head = Head(directory, recipe_loader, sous, groups, secret_access, pools)
|
||||||
head._load_variables()
|
head._load_variables()
|
||||||
head._load_menus()
|
head._load_menus(menu_subset)
|
||||||
return head
|
return head
|
||||||
|
|
||||||
def _preload_variables(self, who_for: str) -> Tuple[dict, dict]:
|
def _preload_variables(self, who_for: str) -> Tuple[dict, dict]:
|
||||||
@ -159,8 +159,12 @@ class Head:
|
|||||||
|
|
||||||
self.variables[sous_name] = sous_vars
|
self.variables[sous_name] = sous_vars
|
||||||
|
|
||||||
def _load_menus(self):
|
def _load_menus(self, subset: Optional[List[str]]):
|
||||||
loader = MenuLoader(Path(self.directory, "menu"), self)
|
loader = MenuLoader(Path(self.directory, "menu"), self)
|
||||||
|
if subset:
|
||||||
|
for unit in subset:
|
||||||
|
loader.load(unit)
|
||||||
|
else:
|
||||||
loader.load_menus_in_dir()
|
loader.load_menus_in_dir()
|
||||||
loader.dagify_all()
|
loader.dagify_all()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user