Animated Circular Progress Bar0
Font.Lokio
CLI

Commands

Complete documentation of all available commands in Lokio CLI


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 init

Apa yang dilakukan:

  • Membuat lokio.yaml dengan default configuration
  • Membuat folder lokio/
  • Membuat folder lokio/templates/
  • Membuat lokio/configs.yaml dengan 1 contoh template
  • Membuat lokio/templates/example.lokio sebagai contoh

Behavior:

  • Jika lokio.yaml sudah 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.lokio

lokio list / lokio ls#

List semua template yang tersedia.

Usage:

lokio list
lokio ls
lokio template list
lokio template ls

Output:

┌  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 gen

Flow:

  1. Tampilkan list template yang tersedia
  2. User pilih template
  3. Prompt untuk setiap parameter (sesuai configs.yaml)
  4. Generate file ke output path
  5. Tanya overwrite jika file sudah ada

Example:

$ lokio generate
  Lokio CLI - Generate code

  Choose template:
 example
    hooks

  Component name: button

  Generated: src/components/button.tsx

Behavior:

  • 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 add

Interactive Prompts:

  1. Template name

    • Nama template (unique)
    • Hanya boleh: letters, numbers, hyphens, underscores
    • Validasi: tidak boleh duplikat
  2. Description

    • Deskripsi template
    • Akan ditampilkan di lokio list
  3. Output path

    • Path output dengan EJS syntax
    • Contoh: src/components/<%= name %>.tsx
    • Contoh: src/hooks/use<%= name %>.ts
  4. Template file path

    • Path relatif ke lokio/templates/
    • Contoh: component.lokio
    • Default: <template-name>.lokio
  5. 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:

  1. Confirm deletion
  2. Remove dari configs.yaml
  3. 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#

CommandAliases
lokio generatelokio gen
lokio listlokio ls
lokio template listlokio template ls
lokio template removelokio template rm

Global Options#

Semua commands support:

  • --help, -h - Show help
  • --version, -V - Show version

Example:

lokio --help
lokio generate --help
lokio template --help

Error 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"