optixlog init
Select which projects to manage and write optixlog.toml into the current directory. Idempotent by default.
optixlog init fetches the list of projects accessible to your API key, lets you select which ones to include, and writes optixlog.toml into the current directory. This file is the source of truth for what optixlog generate builds. Commit it — it contains no secrets.
The command is idempotent by default: if optixlog.toml already exists and --force is not passed, the file is left untouched and no backend call is made.
Synopsis
optixlog init [OPTIONS]Flags
Prop
Type
Control flow
Locate target
Computes the write path as --config-path if given, otherwise <cwd>/optixlog.toml.
If the file already exists and --force is not set, prints:
./optixlog.toml already exists; skipping (use --force to overwrite).…and returns 0 without contacting the backend.
Resolve credentials
Resolves the base URL (--base-url → OPTIXLOG_BASE_URL → stored profile → default) and API key:
- With
--fixtureorOPTIXLOG_FIXTUREactive, the key is resolved silently (fixture requires no auth). - Otherwise, if a saved login exists and you are in interactive mode, the CLI prompts:
Use saved login (you@org.com)? [Y/n]. Answering no asks for a one-off key that is used for this run only and is never persisted. - With
--no-input, the saved key is reused automatically. If no key is available, the command exits 1.
List accessible projects
Calls the backend's list_accessible_projects(). If the result is empty, exits with:
error: no accessible projects for this key.Select projects
The selection path depends on the flags you pass:
| Flags | Behavior |
|---|---|
--all | Selects every accessible project. |
--project <token> (one or more) | Matches each token against project id, then case-folded name. Unmatched tokens exit 1. |
--no-input with neither of the above | Exits 1: pass --all or --project in non-interactive use (--no-input). |
| Neither (interactive) | Shows a checkbox picker (if questionary is installed and stdin is a TTY), or a numbered list otherwise. |
Duplicate selections collapse by id. Server ordering is preserved.
Prompt for output path and module style
If --output is not provided, prompts with default optixlog_gen.py. With --no-input, uses the default.
If --module-style is not provided, prompts single_file/package with default single_file. With --no-input, uses the default.
Write optixlog.toml
Writes the file at the target path and prints:
Wrote ./optixlog.toml with 2 project(s): Grating Coupler Lab, Modulator Program.What gets written
[optixlog]
api_base_url = "https://optixlog.leidos.com"
schema_version = 1
[codegen]
output_path = "optixlog_gen.py"
module_style = "single_file"
[[projects]]
id = "proj_grating_7f3a"
name = "Grating Coupler Lab"
[[projects]]
id = "proj_modulator_22b1"
name = "Modulator Program"Node-to-project mapping
The [[projects]] array records which projects to generate types for. Which node types belong to each project is derived from that project's schema at generate time — it is never stored in optixlog.toml.
Idempotency
Without --force, an existing config is left completely untouched — no backend call is made. With --force, the file is regenerated from a fresh backend listing and the current flags.
Interactive project selection
When neither --all nor --project nor --no-input is given, init prompts you to pick projects:
- If
questionaryis installed and stdin is a TTY, a checkbox picker is shown. Each item is displayed as<name> (<id>). - Otherwise, a numbered list is printed and you enter comma-separated numbers or
all.
Accessible projects:
1. Grating Coupler Lab (proj_grating_7f3a)
2. Modulator Program (proj_modulator_22b1)
Enter numbers (comma-separated) or 'all': 1,2Usage examples
optixlog initPrompts you to pick projects, output path, and module style.
optixlog init --all --output optixlog_gen.py --module-style single_file --no-inputSelects all accessible projects, uses the given output path and style, never prompts. Suitable for CI.
# By id
optixlog init --project proj_grating_7f3a --project proj_modulator_22b1
# By name (case-insensitive)
optixlog init --project "Grating Coupler Lab" --project "Modulator Program"Selects exactly the named projects. Repeatable.
optixlog init --all --forceRegenerates optixlog.toml even if it already exists — useful after your project list changes.
Offline example
optixlog init \
--fixture tests/fixtures/schema.sample.json \
--all \
--output optixlog_gen.py \
--no-inputErrors
| Condition | Message | Exit code |
|---|---|---|
| No API key and no fixture | error: an API key is required (run \optixlog login`, pass --api-key, or set OPTIXLOG_API_KEY).` | 1 |
--no-input with no project selector | error: pass --all or --project in non-interactive use (--no-input). | 1 |
| Token does not match any project | error: no accessible project matches 'bad-name' | 1 |
| Empty project selection | error: no projects selected. | 1 |
| No accessible projects for the key | error: no accessible projects for this key. | 1 |
Invalid --module-style choice (interactive) | error: invalid choice 'foo'; pick one of single_file, package | 1 |