@@ -34,33 +34,57 @@ const (
3434
3535var cmdGenerate = & cli.Command {
3636 Short : "generate generates client library code for a single API" ,
37- UsageLine : "librarian generate -source=<api-root> -api=<api-path> [flags]" ,
38- Long : `Specify the API repository root and the path within it for the API to generate.
39- Optional flags can be specified to use a non-default language repository, and to indicate whether or not
40- to build the generated library.
41-
42- The generate command handles both onboarding new libraries and regenerating existing ones.
43- The behavior is determined by the provided flags.
44-
45- **Onboarding a new library:**
46- To configure and generate a new library, specify both the "-api" and "-library" flags. This process involves:
47- 1. Running the "configure" command in the language container to set up the repository.
48- 2. Adding the new library's configuration to the ".librarian/state.yaml" file.
49- 3. Proceeding with the generation steps below.
50-
51- **Regenerating existing libraries:**
52- If only "-api" or "-library" is specified, the command regenerates that single, existing library.
53- If neither flag is provided, it regenerates all libraries listed in ".librarian/state.yaml".
54-
55- The generation process for an existing library involves delegating to the language container's
56- 'generate' command. After generation, the tool cleans the destination directory and copies the
57- new files into place, according to the configuration in '.librarian/state.yaml'.
58- If the '--build' flag is specified, the 'build' command is also executed.
59-
60- **Output:**
61- After generation, if the "-push" flag is provided, the changes are committed to a new branch, and
62- a pull request is created. Otherwise, the changes are left in the local working tree for
63- inspection.` ,
37+ UsageLine : "librarian generate [flags]" ,
38+ Long : `The generate command is the primary tool for all code generation
39+ tasks. It handles both the initial setup of a new library (onboarding) and the
40+ regeneration of existing ones. Librarian works by delegating language-specific
41+ tasks to a container, which is configured in the .librarian/state.yaml file.
42+ Librarian is environment aware and will check if the current directory is the
43+ root of a librarian repository. If you are not executing in such a directory the
44+ '--repo' flag must be provided.
45+
46+ # Onboarding a new library
47+
48+ To configure and generate a new library for the first time, you must specify the
49+ API to be generated and the library it will belong to. Librarian will invoke the
50+ 'configure' command in the language container to set up the repository, add the
51+ new library's configuration to the '.librarian/state.yaml' file, and then
52+ proceed with generation.
53+
54+ Example:
55+ librarian generate --library=secretmanager --api=google/cloud/secretmanager/v1
56+
57+ # Regenerating existing libraries
58+
59+ You can regenerate a single, existing library by specifying either the library
60+ ID or the API path. If no specific library or API is provided, Librarian will
61+ regenerate all libraries listed in '.librarian/state.yaml'.
62+
63+ Examples:
64+ # Regenerate a single library by its ID
65+ librarian generate --library=secretmanager
66+
67+ # Regenerate a single library by its API path
68+ librarian generate --api=google/cloud/secretmanager/v1
69+
70+ # Regenerate all libraries in the repository
71+ librarian generate
72+
73+ # Workflow and Options:
74+
75+ The generation process involves delegating to the language container's
76+ 'generate' command. After the code is generated, the tool cleans the destination
77+ directories and copies the new files into place, according to the configuration
78+ in '.librarian/state.yaml'.
79+
80+ - If the '--build' flag is specified, the 'build' command is also executed in
81+ the container to compile and validate the generated code.
82+ - If the '--push' flag is provided, the changes are committed to a new branch,
83+ and a pull request is created on GitHub. Otherwise, the changes are left in
84+ your local working directory for inspection.
85+
86+ Example with build and push:
87+ SDK_LIBRARIAN_GITHUB_TOKEN=xxx librarian generate --push --build` ,
6488 Run : func (ctx context.Context , cfg * config.Config ) error {
6589 runner , err := newGenerateRunner (cfg , nil , nil )
6690 if err != nil {
0 commit comments