Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test
# cargo test never opens a terminal, so it cannot see #30: with stdin piped,
# crossterm reads keys from /dev/tty, and on macOS that failed at startup.
# `script` provides the pty; the data comes down the pipe, `q` through the tty.
- name: Piped stdin smoke test
if: runner.os == 'macOS'
timeout-minutes: 2
run: |
cargo build
(sleep 5; printf q) | script -q /dev/null sh -c \
'stty rows 40 cols 120; cat tests/fixtures/orders.json | target/debug/datasight; echo $? > rc'
test "$(cat rc)" = 0

clippy:
name: Clippy
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed
- Piping data into datasight works on macOS (#30). Any piped input — `cat data.csv | datasight`, an HTTP response, anything — died at startup with `Failed to initialize input reader`: with stdin taken by the pipe, keys are read from `/dev/tty`, and the default event source waits on it through kqueue, which macOS does not support for terminals. crossterm's `use-dev-tty` feature reads the tty with a source that works there. CI now runs a piped-stdin smoke test on macOS inside a pty, since `cargo test` never opens a terminal and could not catch this.
- `datasight <(cmd)` loads the data instead of failing with `Unsupported file format: .` A path without an extension (process substitution hands over `/dev/fd/N`) is now identified from its content, the same way stdin is: `[` is JSON, `{` is NDJSON, anything else is CSV.

## [0.10.0] - 2026-08-23

### Added
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ azure = ["dep:object_store", "object_store/azure", "dep:tokio"]
aws = ["dep:object_store", "object_store/aws", "dep:tokio"]

[dependencies]
crossterm = { version = "0.29.0", features = ["osc52"] }
crossterm = { version = "0.29.0", features = ["osc52", "use-dev-tty"] }
ratatui = "0.30.0"
polars = { version = "0.46", features = ["csv", "parquet", "lazy", "strings", "regex", "json", "temporal", "dtype-date", "dtype-datetime", "dtype-decimal", "dtype-duration", "dtype-time"] }
clap = { version = "4", features = ["derive"] }
Expand Down
5 changes: 5 additions & 0 deletions qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ launch "cat tests/fixtures/orders.json | $BINARY"
assert_contains "A/stdin-json" "order_id"
quit

# process substitution: the path is /dev/fd/N, no extension to dispatch on (#30)
launch "$BINARY <(cat tests/fixtures/orders.json)"
assert_contains "A/procsub-json" "order_id"
quit

# ── Suite B: Normal mode navigation ───────────────────────────────────────────
echo ""
echo "=== Suite B: Normal mode navigation ==="
Expand Down
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ pub(crate) fn load_dataframe(
.with_json_format(JsonFormat::Json)
.finish()?,
"ndjson" | "jsonl" => JsonLineReader::new(std::fs::File::open(file_path)?).finish()?,
// No extension to go on — e.g. `<(cmd)` hands us /dev/fd/63, a pipe that can
// only be read once — so sniff the content the same way stdin does.
"" => return parse_buf(std::fs::read(file_path)?, delimiter),
_ => {
if let Some(sep) = delimiter {
csv_options(sep)
Expand Down Expand Up @@ -547,6 +550,17 @@ mod tests {
assert!(load_dataframe("tests/fixtures/orders.csv.bak", None).is_err());
}

#[test]
fn test_no_extension_sniffs_content() {
// Stands in for `datasight <(cmd)`, whose /dev/fd/N path has no extension (#30).
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("orders");
std::fs::copy("tests/fixtures/orders.json", &path).unwrap();
let df = load_dataframe(path.to_str().unwrap(), None).expect("should sniff as JSON");
let expected = load_dataframe("tests/fixtures/orders.json", None).unwrap();
assert!(df.equals_missing(&expected));
}

#[test]
fn test_try_parse_date_columns_mm_dd_yyyy() {
// Non-ISO date strings like "12/25/2022" are sorted lexicographically
Expand Down
Loading