Help us shape the future of Go! Take the 2026 Go Developer Survey

ndql

module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 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 QUERY [PATH] [flags]

Flags:
  -c, --concurrency uint   maximum number of goroutines to process query, 0 means 1
      --debug              enable debug logs
  -h, --help               help for query
  -i, --index string       index source; exclusive with paths
  -q, --quiet              quiet logs except errors
      --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
gendoc command
ndql command
pkg
iox
run

Jump to

Keyboard shortcuts

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