Commands#
Dokumentasi lengkap semua commands yang tersedia di Lokio CLI.
Overview#
lokio [command] [options]Commands List#
lokio init#
Initialize Lokio di project saat ini.
Usage:
lokio initApa yang dilakukan:
- Membuat
lokio.yamldengan default configuration - Membuat folder
lokio/ - Membuat folder
lokio/templates/ - Membuat
lokio/configs.yamldengan 1 contoh template - Membuat
lokio/templates/example.lokiosebagai contoh
Behavior:
- Jika
lokio.yamlsudah ada, akan ditanya apakah ingin overwrite - Jika sudah di-initialize sebelumnya, bisa skip atau overwrite
Example:
$ lokio init
┌ Lokio CLI - Initialize project
│
✓ Initialization complete!
│
Note: Created:
- lokio.yaml
- lokio/configs.yaml
- lokio/templates/
- lokio/templates/example.lokiolokio list / lokio ls#
List semua template yang tersedia.
Usage:
lokio list
lokio ls
lokio template list
lokio template lsOutput:
┌ Lokio CLI - List templates
│
📄 example
Description: Example React component template
Output: src/components/<%= name %>.tsx
Parameters: 1
- name (string, required)
📄 hooks
Description: React hook template
Output: src/hooks/use<%= name %>.ts
Parameters: 2
- name (string, required)
- withState (boolean, optional)
Info yang ditampilkan:
- Template name
- Description
- Output path pattern
- Jumlah parameters
- Detail parameters (name, type, required/optional)
lokio generate / lokio gen#
Generate code dari template yang dipilih.
Usage:
lokio generate
lokio genFlow:
- Tampilkan list template yang tersedia
- User pilih template
- Prompt untuk setiap parameter (sesuai configs.yaml)
- Generate file ke output path
- Tanya overwrite jika file sudah ada
Example:
$ lokio generate
┌ Lokio CLI - Generate code
│
◆ Choose template:
│ ❯ example
│ hooks
│
◆ Component name: button
│
✓ Generated: src/components/button.tsxBehavior:
- Jika hanya ada 1 template, tetap tampilkan pilihan
- Parameters required ditanyakan dulu
- Parameters optional dengan default value
- File yang sudah ada akan ditanya overwrite
lokio template add#
Tambah template baru dengan interactive prompts.
Usage:
lokio template addInteractive Prompts:
-
Template name
- Nama template (unique)
- Hanya boleh: letters, numbers, hyphens, underscores
- Validasi: tidak boleh duplikat
-
Description
- Deskripsi template
- Akan ditampilkan di
lokio list
-
Output path
- Path output dengan EJS syntax
- Contoh:
src/components/<%= name %>.tsx - Contoh:
src/hooks/use<%= name %>.ts
-
Template file path
- Path relatif ke
lokio/templates/ - Contoh:
component.lokio - Default:
<template-name>.lokio
- Path relatif ke
-
Parameters (bisa tambah multiple)
- Parameter name
- Type: string, boolean, number
- Required: yes/no
- Prompt text
- Default value (optional)
Example:
$ lokio template add
┌ Lokio CLI - Add template
│
◆ Template name: hooks
◆ Template description: React hook template
◆ Output path: src/hooks/use<%= name %>.ts
◆ Template file path: hook.lokio
◆ Parameter name: name
◆ Parameter type: String
◆ Required?: Yes
◆ Prompt text: Hook name (without 'use' prefix)
◆ Add another parameter?: No
│
✓ Created template file: hook.lokio
✓ Template 'hooks' added successfully!Note:
- Template file akan dibuat dengan default content jika belum ada
- Bisa edit template file dan configs.yaml secara manual setelah ini
lokio template remove / lokio template rm#
Hapus template dari project.
Usage:
lokio template remove <name>
lokio template rm <name>Arguments:
<name>- Nama template yang akan dihapus (required)
Flow:
- Confirm deletion
- Remove dari configs.yaml
- Tanya apakah ingin hapus template file juga
Example:
$ lokio template remove hooks
┌ Lokio CLI - Remove template
│
◆ Are you sure you want to remove template 'hooks'? No / Yes
◆ Delete template file 'hook.lokio'? No / Yes
│
✓ Template 'hooks' removed successfully!Behavior:
- Template akan dihapus dari configs.yaml
- Template file bisa dipilih untuk dihapus atau tidak
- Jika template tidak ditemukan, akan error
Command Aliases#
| Command | Aliases |
|---|---|
lokio generate | lokio gen |
lokio list | lokio ls |
lokio template list | lokio template ls |
lokio template remove | lokio template rm |
Global Options#
Semua commands support:
--help, -h- Show help--version, -V- Show version
Example:
lokio --help
lokio generate --help
lokio template --helpError Handling#
Jika ada error, CLI akan menampilkan pesan error yang jelas:
- File tidak ditemukan → "Run 'lokio init' first"
- Template tidak ditemukan → "Template 'xxx' not found"
- Invalid config → "Invalid configs.yaml format"
- Template file tidak ada → "Template file not found: xxx"