ndql

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: MIT

README

ndql

Select metadata from files by SQL.

Usage

❯ ndql help query
Run query.

## QUERY, PATH
- @stdin or @-: from stdin
- @FILENAME: from file
- otherwise: as it is

## Examples

List all files and directories under the dir:

    ndql query 'select *' dir

List all file paths under the dir:

    ndql query 'select path where not is_dir' dir

Add a "count" column for the number of times 'keyword' appears in the file:

    ndql query 'select sh("echo count=$(grep -c keyword $(get path))") where not is_dir'

Roughly list the Go func in the file except tests:

    ndql query 'select path, func from (select grep("func (?P<name>[^(]+)", "func=$name") where not is_dir and path not like "%_test.go")' dir

Add the line number where each func is defined as 'line':

    ndql query 'select path, func from (select grep("func (?P<name>[^(]+)", "func=$name") where not is_dir and path not like "%_test.go")' dir | ndql query 'select sh("echo line=$(grep -n \"func $(get func)\" $(get path) | cut -d: -f1)")' -i@-

Roughly lists the names and values of variables exported in bash format. The search is restricted only to files tracked by git:

    git ls-files | ndql query 'select grep("export (?P<name>[^=]+)=(?P<value>.+)", "name=$name,value=$value") where not is_dir' @-

Extracts metadata from mp3 and m4a files using ffprobe:

    ndql query 'select sh("ffprobe -v error -hide_banner -show_entries format -of json=c=1 \"$(get path)\" | jq .format.tags -c") where not is_dir and extension(path) in (".mp3", ".m4a")' dir

Usage:
  ndql query QUERT [PATH] [flags]

Flags:
      --debug          enable debug logs
  -h, --help           help for query
  -i, --index string   index source; exclusive with paths
  -q, --quiet          quiet logs
      --raw            enable raw output
      --trace          enable trace logs
  -v, --verbose        enable verbose output

Documents

See docs

Install

make
bin/ndql help

Directories

Path Synopsis
cmd
ndql command
pkg
iox
run

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL