OptixLog Docs
CLICommands

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 --fixture or OPTIXLOG_FIXTURE active, 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:

FlagsBehavior
--allSelects 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 aboveExits 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.toml
[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 questionary is 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,2

Usage examples

optixlog init

Prompts you to pick projects, output path, and module style.

optixlog init --all --output optixlog_gen.py --module-style single_file --no-input

Selects 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 --force

Regenerates 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-input

Errors

ConditionMessageExit code
No API key and no fixtureerror: an API key is required (run \optixlog login`, pass --api-key, or set OPTIXLOG_API_KEY).`1
--no-input with no project selectorerror: pass --all or --project in non-interactive use (--no-input).1
Token does not match any projecterror: no accessible project matches 'bad-name'1
Empty project selectionerror: no projects selected.1
No accessible projects for the keyerror: no accessible projects for this key.1
Invalid --module-style choice (interactive)error: invalid choice 'foo'; pick one of single_file, package1

On this page