How to Use in Command Line

How to Use in Command Line

IWE provides a powerful command-line interface for managing markdown-based knowledge graphs. The CLI enables you to initialize projects, normalize documents, explore connections, export visualizations, and create consolidated documents.

Quick Start

  1. Initialize a project: iwe init
  2. Create a new document: iwe new "My Note"
  3. Retrieve a document with context: iwe retrieve -k my-note
  4. Find and search documents: iwe find "search term"
  5. Normalize all documents: iwe normalize
  6. View document hierarchy: iwe tree
  7. Analyze your knowledge base: iwe stats
  8. Export graph visualization: iwe export dot
  9. Rename a document: iwe rename old-key new-key
  10. Delete a document: iwe delete document-key
  11. Extract a section: iwe extract document --section "Title"
  12. Inline a reference: iwe inline document --reference "other-doc"

Installation & Setup

Before using the CLI, ensure IWE is installed and available in your PATH. Initialize any directory as an IWE project:

cd your-notes-directory
iwe init

This creates a .iwe/ directory with configuration files.

Global Usage

iwe [OPTIONS] <COMMAND>

Global Options

  • -V, --version: Display version information
  • -v, --verbose <LEVEL>: Set verbosity level (default: 0)
    • 1: Minimal output (INFO level messages to stderr)
    • 2 or higher: Debug-level information to stderr
  • -h, --help: Show help information

Configuration

Commands respect settings in .iwe/config.toml:

[library]
path = ""  # Subdirectory containing markdown files

[markdown]
normalize_headers = true
normalize_lists = true

Command Categories

Document Management

CommandDescriptionDocumentation
initInitialize a new IWE projectIWE Init
newCreate a new documentIWE New
normalizeNormalize all documentsIWE Normalize

Document Retrieval

CommandDescriptionDocumentation
retrieveRetrieve document with contextIWE Retrieve
findSearch and discover documentsIWE Find
treeDisplay document hierarchyIWE Tree

Refactoring Operations

CommandDescriptionDocumentation
renameRename a document and update referencesIWE Rename
deleteDelete a document and clean up referencesIWE Delete
extractExtract a section to a new documentIWE Extract
inlineInline a referenced documentIWE Inline

Analysis & Export

CommandDescriptionDocumentation
statsAnalyze knowledge base statisticsIWE Stats
exportExport graph visualizationIWE Export
squashSquash documentsIWE Squash

Exit Codes

CodeMeaning
0Success - command completed without errors
1Error - invalid arguments, missing files, operation failed

All commands return exit code 0 on success. On error, commands print a message to stderr and return exit code 1.

# Check exit code
iwe find "nonexistent-query"
echo $?  # Returns 0 (empty result is not an error)

iwe retrieve --key "missing-doc"
echo $?  # Returns 1 (document not found is an error)