Skip to content

Commit 1918a52

Browse files
authored
feat: add cli args for configure (#14507)
Towards googleapis/librarian#466 🦕
1 parent 692a39c commit 1918a52

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

.generator/cli.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,35 @@ def _write_json_file(path: str, updated_content: Dict):
115115
f.write("\n")
116116

117117

118-
def handle_configure():
118+
def handle_configure(
119+
librarian: str = LIBRARIAN_DIR,
120+
source: str = SOURCE_DIR,
121+
repo: str = REPO_DIR,
122+
input: str = INPUT_DIR,
123+
):
124+
"""Onboards a new library by completing its configuration.
125+
126+
This function reads a partial library definition from `configure-request.json`,
127+
fills in missing fields like the version, source roots, and preservation
128+
rules, and writes the complete configuration to `configure-response.json`.
129+
It ensures that new libraries conform to the repository's standard structure.
130+
131+
See https://github.com/googleapis/librarian/blob/main/doc/container-contract.md#configure-container-command
132+
133+
Args:
134+
librarian(str): Path to the directory in the container which contains
135+
the librarian configuration.
136+
source(str): Path to the directory in the container which contains
137+
API protos.
138+
repo(str): This directory will contain all directories that make up a
139+
library, the .librarian folder, and any global file declared in
140+
the config.yaml.
141+
input(str): The path to the directory in the container
142+
which contains additional generator input.
143+
144+
Raises:
145+
ValueError: If configuring a new library fails.
146+
"""
119147
# TODO(https://github.com/googleapis/librarian/issues/466): Implement configure command and update docstring.
120148
logger.info("'configure' command executed.")
121149

@@ -407,7 +435,7 @@ def _run_nox_sessions(library_id: str, repo: str):
407435
Args:
408436
library_id(str): The library id under test.
409437
repo(str): This directory will contain all directories that make up a
410-
library, the .librarian folder, and any global file declared in
438+
library, the .librarian folder, and any global files declared in
411439
the config.yaml.
412440
"""
413441
sessions = [
@@ -997,7 +1025,14 @@ def handle_release_init(
9971025
args = parser.parse_args()
9981026

9991027
# Pass specific arguments to the handler functions for generate/build
1000-
if args.command == "generate":
1028+
if args.command == "configure":
1029+
args.func(
1030+
librarian=args.librarian,
1031+
source=args.source,
1032+
repo=args.repo,
1033+
input=args.input,
1034+
)
1035+
elif args.command == "generate":
10011036
args.func(
10021037
librarian=args.librarian,
10031038
source=args.source,

0 commit comments

Comments
 (0)