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.
Run this command from within the directory you want to initialize:
cd /path/to/your-librarykilm init [OPTIONS]
Options
Section titled “Options”Option | Description | Default | Example |
---|---|---|---|
--name TEXT | Custom name for the library collection | Auto-generated from directory name | --name my-custom-library |
--description TEXT | Description for the library metadata | None | --description "My collection of custom components" |
--env-var TEXT | Custom KiCad environment variable name | Auto-generated (e.g., KICAD_LIB_MY_LIBRARY ) | --env-var MY_LIB_PATH |
--no-env-var | Don’t assign an environment variable to this library | False | --no-env-var |
--set-current/--no-set-current | Set this as the current active library | True | --no-set-current |
--force | Overwrite existing metadata file if present | False | --force |
--help | Show help message and exit | - | --help |
Behavior
Section titled “Behavior”The command performs the following actions:
-
Creates Directory Structure: Creates standard subdirectories (
symbols/
,footprints/
,templates/
) if they don’t exist -
Creates Template Files: Creates a template
library_descriptions.yaml
file for richer KiCad descriptions -
Creates/Updates Metadata: Creates or modifies
kilm.yaml
with library information:- Library name, description, and environment variable
- Detected capabilities (symbols, footprints, templates)
- Last updated timestamp
-
Updates Global Configuration: Adds library entry (type
github
) to mainconfig.yaml
-
Sets Default Library: Optionally sets this library as the current active library
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”Initialize current directory as KiCad library:
# Navigate to your library directorycd ~/my-kicad-libraries
# Initialize with default settingskilm init
Initialize with custom name and description:
cd ~/company-componentskilm init --name company-symbols --description "Company-wide KiCad components"
Advanced Configuration
Section titled “Advanced Configuration”Initialize with custom environment variable:
cd ~/project-librarieskilm init --name project-libs --description "Project-specific components" --env-var PROJECT_COMPONENTS --no-set-current
Force re-initialization:
cd ~/existing-librarykilm init --force --name updated-library
Workflow Examples
Section titled “Workflow Examples”Complete library setup workflow:
# 1. Create and initialize librarymkdir ~/my-symbols && cd ~/my-symbolskilm init --name my-symbols --description "My custom symbols"
# 2. Add your symbol files to symbols/ directory# Copy your .kicad_sym files to symbols/
# 3. Configure KiCad to use the librarykilm setup
# 4. Verify setupkilm status
Error Handling
Section titled “Error Handling”Common Issues
Section titled “Common Issues”- Permission denied: Command will fail if unable to create directories or files
- Existing library: Use
--force
to overwrite existing metadata - Invalid directory: Command must be run in a writable directory
- Configuration error: Command will fail if unable to update global config
Error Examples
Section titled “Error Examples”# No write permissionscd /readonly/directorykilm init# Error: Permission denied when creating directories
# Directory doesn't existcd /nonexistent/pathkilm init# Error: Directory does not exist
Integration with Other Commands
Section titled “Integration with Other Commands”Typical Workflow
Section titled “Typical Workflow”After running kilm init
, you typically need to:
- Add your library files: Place
.kicad_sym
files insymbols/
,.pretty
directories infootprints/
- Run setup: Execute
kilm setup
to configure KiCad to use the library - Verify: Use
kilm status
to check that everything is configured correctly
Generated Files
Section titled “Generated Files”The command creates the following files and directories:
Directory Structure
Section titled “Directory Structure”Directoryyour-library
Directorysymbols/ # Directory for .kicad_sym files
- …
Directoryfootprints/ # Directory for .pretty directories
- …
Directorytemplates/ # Directory for project templates
- …
- kilm.yaml # Library metadata (created/updated)
- library_descriptions.yaml # KiCad descriptions (created if missing)
Metadata File
Section titled “Metadata File”name: "my-library"description: "My KiCad library"env_var: "KICAD_LIB_MY_LIBRARY"capabilities:symbols: truefootprints: truetemplates: falseversion: "1.0.0"updated_with: "kilm"
- Working Directory: Command must be run from within the directory you want to initialize
- Environment Variables: Use
kilm setup
to activate configured environment variables in KiCad - Cross-platform: Works on Windows, macOS, and Linux with appropriate path handling
- Git Integration: Designed for Git-managed libraries but works with any directory structure
- Safe Updates: Preserves existing metadata unless
--force
is used