init
The kilm init
command prepares the current working directory to be managed by KiLM as a library collection, primarily intended for symbol, footprint, and template libraries (often managed via Git, hence the internal type github
).
It performs several actions:
- Creates standard subdirectories (
symbols/
,footprints/
,templates/
) if they don’t exist. - Creates a template
library_descriptions.yaml
file if it doesn’t exist, used for richer descriptions in KiCad. - Creates or updates a metadata file named
kilm.yaml
within the current directory. This stores the library’s name, description, associated environment variable, and detected capabilities (symbols, footprints, templates). - Adds an entry for this library (with its path and type
github
) to the main KiLM configuration file (~/.config/kicad-lib-manager/config.yaml
). - Optionally sets this library as the
current_library
in the main configuration.
Usage
Run this command from within the directory you want to initialize:
cd /path/to/your-librarykilm init [OPTIONS]
Options
-
--name TEXT
: Sets a custom name for the library collection. If not provided, a name is generated from the current directory name. Example:kilm init --name my-custom-library
-
--description TEXT
: Adds a description to the library metadata (kilm.yaml
). Example:kilm init --description "My collection of custom components"
-
--env-var TEXT
: Specifies a custom KiCad environment variable name (e.g.,MY_CUSTOM_LIB
) to associate with this library’s path. If not provided (and--no-env-var
isn’t used), a name is automatically generated (e.g.,KICAD_LIB_MY_CUSTOM_LIBRARY
). This variable will be set in KiCad when you runkilm setup
. Example:kilm init --env-var MY_LIB_PATH
-
--no-env-var
: Prevents an environment variable from being assigned to this library in the metadata. Default:False
. Example:kilm init --no-env-var
-
--set-current / --no-set-current
: Controls whether this library should be set as thecurrent_library
in the mainconfig.yaml
. Default:--set-current
. Example:kilm init --no-set-current
-
--force
: Ifkilm.yaml
already exists, overwrite it with new metadata based on options or defaults. Without--force
, existing metadata is updated only with explicitly provided options. Default:False
. Example:kilm init --force
-
--help
: Show the help message and exit.
Behavior Summary
- Target: Current working directory.
- Creates/Updates:
symbols/
,footprints/
,templates/
dirs,library_descriptions.yaml
,kilm.yaml
. - Modifies Global Config: Adds library entry to main
config.yaml
, optionally setscurrent_library
. - Library Type: Registers the library with type
github
inconfig.yaml
.
Examples
Basic Initialization: Initialize the current directory, creating folders and metadata, using default names/env vars, and setting it as current.
cd /path/to/my-kicad-librarykilm init
Initialization with Options: Initialize with a specific name, description, and environment variable, and don’t set it as the current library.
cd /path/to/another-kicad-librarykilm init --name project-specific --description "Components for Project X" --env-var PROJECT_X_LIBS --no-set-current
Re-initialize with Force:
Overwrite existing kilm.yaml
with default settings.
cd /path/to/existing-librarykilm init --force
Note: Running kilm init
registers the library with KiLM and prepares the directory. You still need to run kilm setup
afterwards to make KiCad aware of this library by updating KiCad’s configuration files.