lunapi.cli

Command-line interface for the common Luna sample-list workflow.

This module deliberately contains only the command-line adapter. Luna options, parameter files, sample-list loading, EDF attachment, command evaluation, and output writing continue to be handled by the existing lunapi/C++ APIs.

Attributes

HELP

Exceptions

CLIError

A user-facing command-line parsing or usage error.

Classes

ParameterAction

An option to apply through the existing Luna API.

CLIConfig

Parsed configuration for the ordinary Luna CLI workflow.

Functions

parse_args(argv) → CLIConfig

Parse the supported Luna command-line grammar without side effects.

main([argv]) → int

Run the luna.py command-line interface and return an exit code.

Module Contents

lunapi.cli.HELP = Multiline-String[source]
Show Value
"""Usage:
  luna.py SAMPLE_LIST [options] [LUNA_VARIABLES...] -s "COMMANDS"
  luna.py EDF        [options] [LUNA_VARIABLES...] -s "COMMANDS"
  luna.py SAMPLE_LIST [options] < command-file

Common examples:
  luna.py s.lst -o out.db sig=EEG @params.txt -s "EPOCH len=30 PSD"
  luna.py s.lst 1 10 -o out.db -s "HEADERS"
  luna.py s.lst subject_001 -o out.db -s "DESC"
  luna.py --build /data/study > s.lst
  luna.py --validate s.lst

Supported interface:
  Input
    SAMPLE_LIST              Tab-delimited ID / EDF / annotation sample list
    EDF                      Process one EDF/EDFZ/REC/SEDF recording

  Output
    -o FILE                  Write one SQLite result database (overwrites it)
    -t DIRECTORY             Write Luna plain-text tables to a directory

  Commands
    -s COMMANDS              Evaluate the remainder of the command line
    stdin                     If -s is omitted, read a command file from stdin

  Luna variables
    key=value                 Set a Luna special variable or option
    @PARAM_FILE               Read a Luna parameter file

  Sample selection
    N                         Select sample-list row N (1-based)
    N-M                       Select an inclusive row range
    N/M                       Select the Luna slice N of M
    ID                        Select a sample-list ID; repeat for multiple IDs

  Supported helper modes
    --build PATH...           Build a sample list using Luna's C++ builder
    --validate SAMPLE_LIST    Validate EDF paths in a sample list
    --version                 Show lunapi and Luna versions
    -h, --help                Show this help

Not currently implemented by this interface:
  -a/--append and Luna's standalone special tools such as --xml, --merge,
  --repath, --gpa, --psc, --pops, and signal/filter design helpers.
  Use the native luna executable for those workflows.
"""
exception lunapi.cli.CLIError[source]

Bases: ValueError

A user-facing command-line parsing or usage error.

class lunapi.cli.ParameterAction[source]

An option to apply through the existing Luna API.

kind: str[source]
key: str = ''[source]
value: str = ''[source]
class lunapi.cli.CLIConfig[source]

Parsed configuration for the ordinary Luna CLI workflow.

input_path: str | None = None[source]
output_db: str | None = None[source]
output_text: str | None = None[source]
command: str | None = None[source]
row_start: int | None = None[source]
row_end: int | None = None[source]
ids: list[str] = [][source]
parameters: list[ParameterAction] = [][source]
mode: str = 'run'[source]
build_args: list[str] = [][source]
lunapi.cli.parse_args(argv: Sequence[str]) → CLIConfig[source]

Parse the supported Luna command-line grammar without side effects.

lunapi.cli.main(argv: Sequence[str] | None = None) → int[source]

Run the luna.py command-line interface and return an exit code.