@glucoseiq/cli
v1.0.0-next.0
Published
Command-line CGM CSV analysis without application code: `npx @glucoseiq/cli report data.csv` prints an analytics summary with metrics, episodes, and an optional AGP-style SVG.
Maintainers
Readme
@glucoseiq/cli
Command-line glucose analysis and AGP-style SVG generation using
@glucoseiq/core. The package exposes the glucoseiq executable and a typed,
injectable run function. Requires Node >=24.
Install
npm install @glucoseiq/cliRun the installed executable:
glucoseiq report data.csv --jsonFirst use as a library
import { type CliIO, run } from '@glucoseiq/cli'
const io: CliIO = {
out(line) {
console.log(line)
},
err(line) {
console.error(line)
},
}
const exitCode: number = run(['report', 'data.csv', '--json'], io)
console.log(`exit ${exitCode}`)Options and defaults
Flags are --timestamp-col, --value-col, --unit, --delimiter,
--timezone, --json, --agp-svg, and --help.
--timestamp-coldefaults toTimestamp.--value-coldefaults toGlucose Value (mg/dL).--unitaccepts mg/dL or mmol/L and defaults to mg/dL.--delimiterdefaults to comma and must be one UTF-16 code unit, excluding double quote, NUL, CR, and LF.--timezonedefaults toUTCin the report pipeline.--jsonwrites the structured result instead of the human summary.--agp-svg <path>also writes the SVG file.--helpprints usage.
The timestamp and value flags map exact CSV columns; they do not select a vendor parser. Success and help return exit code 0; errors return 1.
JSON and SVG output
JSON has the shape { report, glucoseIQ }; non-finite numbers serialize as
null. When --json and --agp-svg are combined, stdout remains one JSON
document and suppresses the SVG success line. The SVG is written to the path
provided to --agp-svg.
Invalid input
Invalid input, unknown flags, unknown commands, unreadable files, files with no
usable rows, and unwritable SVG destinations return exit code 1. Failures are
written as one sanitized stderr line without a stack trace. The library form
returns the code instead of changing process.exitCode.
Safety limits
The CLI inherits the core CSV and analysis boundaries. It reads the requested file into memory and writes only the explicitly requested SVG path; callers remain responsible for file-size controls and trusted path selection in their host environment. Output is informational and not medical advice.
