@unrdf/cli-example-graph-commands
v1.0.0
Published
Custom graph command examples for @unrdf/cli
Readme
Graph Commands Example
Custom CLI commands for graph operations using @unrdf/cli.
Features
- Load RDF graphs from files
- Display graph statistics
- Merge multiple graphs
- Save graphs in various formats
- Custom command definitions with citty
Installation
pnpm installUsage
Load Graph
node src/index.mjs load data/example.ttlDisplay Statistics
node src/index.mjs stats data/example.ttlMerge Graphs
node src/index.mjs merge "data/graph1.ttl,data/graph2.ttl" --output merged.ttl --format turtleCustom Commands
The example demonstrates how to create custom CLI commands:
import { defineCommand } from 'citty';
export const customCommand = defineCommand({
meta: {
name: 'custom',
description: 'Custom command'
},
args: {
input: {
type: 'positional',
description: 'Input file',
required: true
}
},
async run({ args }) {
// Command logic
}
});API
loadGraph(filepath)
Load RDF graph from file into N3 Store.
saveGraph(store, filepath, format)
Save N3 Store to file in specified format.
getGraphStats(store)
Calculate graph statistics (quads, subjects, predicates, objects).
mergeGraphs(stores)
Merge multiple N3 Stores into single store.
Testing
pnpm test