Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ffec773
feat(output): add yaml output
Dustin-Jiang Sep 30, 2025
97d6bfb
docs: update CHANGELOG
Dustin-Jiang Sep 30, 2025
cdb7bc0
fix: escape path, and disable permission display on Windows
Dustin-Jiang Sep 30, 2025
c9cbb25
fix(ci): fix warnings in cargo clippy
Dustin-Jiang Sep 30, 2025
192ca92
refactor: make output stateful
Dustin-Jiang Sep 30, 2025
602b389
feat(output): add json output
Dustin-Jiang Sep 30, 2025
eb2f10d
fix(ci): fix warnings in cargo clippy
Dustin-Jiang Sep 30, 2025
4ea0ed3
fix: fix function calling in Windows
Dustin-Jiang Sep 30, 2025
e225946
fix: fix reference mutable type annotation in Windows
Dustin-Jiang Sep 30, 2025
977ee0e
fix: resolve suggested changes
Dustin-Jiang Oct 10, 2025
6434ee5
fix: move JSON array printing to Printer
Dustin-Jiang Oct 10, 2025
b2d385f
feat: implement NDJSON output
Dustin-Jiang Oct 11, 2025
703b32f
fix(ci): fix warnings in cargo clippy
Dustin-Jiang Oct 11, 2025
650e86c
tests: add tests for `--output` flags
Dustin-Jiang Oct 12, 2025
2e463c7
docs: update manpage for `--output` flags
Dustin-Jiang Oct 12, 2025
e46cce0
Merge branch 'master' into feature-yaml
Dustin-Jiang Oct 13, 2025
10570e9
tests: fix invalid utf8 base64 test
Dustin-Jiang Oct 15, 2025
949a5aa
docs: update manpage to change "ndjson" to "jsonl"
Dustin-Jiang Oct 15, 2025
cb3ef97
fix: change FileDetail creating logic and base64 import
Dustin-Jiang Oct 15, 2025
60ecc09
fix: change ndjson flag to commonly used jsonl
Dustin-Jiang Oct 16, 2025
7c9f1d8
fix: replace String to &str with lifetime, adopt as_encoded_bytes
Dustin-Jiang Oct 29, 2025
2c1bdb5
feat: add --json flag for JSONL output
Dustin-Jiang Oct 29, 2025
e831976
docs: add --json flag to manpage
Dustin-Jiang Oct 29, 2025
30c9e86
Merge branch 'master' into feature-yaml
Dustin-Jiang Oct 29, 2025
49654f4
fix(clippy): collapse if blocks
Dustin-Jiang Nov 2, 2025
e4741c0
Merge remote-tracking branch 'origin/master' into feature-yaml
Dustin-Jiang Nov 2, 2025
4a0ecc5
Merge remote-tracking branch 'origin/master' into feature-yaml
Dustin-Jiang Nov 8, 2025
56d347e
fix: remove the `--output` flag
Dustin-Jiang Nov 8, 2025
6db4409
tests: fix `--output` tests to `--json`
Dustin-Jiang Nov 9, 2025
c2c8497
docs: add fields explaination in manual
Dustin-Jiang Nov 13, 2025
13d0868
docs: change the flag to `--json` in CHANGELOG.md
Dustin-Jiang Nov 13, 2025
47ee6ce
fix(printer): make `Priner.stdout` private
Dustin-Jiang Nov 13, 2025
58b90f7
Merge remote-tracking branch 'origin/master' into feature-yaml
Dustin-Jiang Nov 13, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- Add `--json` flag for JSONL format output.

## Bugfixes

Expand Down
33 changes: 33 additions & 0 deletions Cargo.lock

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

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ description = "fd is a simple, fast and user-friendly alternative to find."
exclude = ["/benchmarks/*"]
homepage = "https://github.com/sharkdp/fd"
documentation = "https://docs.rs/fd-find"
keywords = [
"search",
"find",
"file",
"filesystem",
"tool",
]
keywords = ["search", "find", "file", "filesystem", "tool"]
license = "MIT OR Apache-2.0"
name = "fd-find"
readme = "README.md"
repository = "https://github.com/sharkdp/fd"
version = "10.3.0"
edition= "2024"
edition = "2024"
rust-version = "1.90.0"

[badges.appveyor]
Expand All @@ -43,9 +37,10 @@ anyhow = "1.0"
etcetera = "0.11"
normpath = "1.1.1"
crossbeam-channel = "0.5.15"
clap_complete = {version = "4.5.60", optional = true}
clap_complete = { version = "4.5.60", optional = true }
faccess = "0.2.4"
jiff = "0.2.14"
base64 = "0.22.1"

[dependencies.clap]
version = "4.5.51"
Expand All @@ -57,7 +52,11 @@ default-features = false
features = ["nu-ansi-term"]

[target.'cfg(unix)'.dependencies]
nix = { version = "0.30.1", default-features = false, features = ["signal", "user", "hostname"] }
nix = { version = "0.30.1", default-features = false, features = [
"signal",
"user",
"hostname",
] }

[target.'cfg(all(unix, not(target_os = "redox")))'.dependencies]
libc = "0.2"
Expand All @@ -68,13 +67,14 @@ libc = "0.2"
# This has to be kept in sync with src/main.rs where the allocator for
# the program is set.
[target.'cfg(all(not(windows), not(target_os = "android"), not(target_os = "macos"), not(target_os = "freebsd"), not(target_os = "openbsd"), not(target_os = "illumos"), not(all(target_env = "musl", target_pointer_width = "32")), not(target_arch = "riscv64")))'.dependencies]
tikv-jemallocator = {version = "0.6.0", optional = true}
tikv-jemallocator = { version = "0.6.0", optional = true }

[dev-dependencies]
diff = "0.1"
tempfile = "3.23"
filetime = "0.2"
test-case = "3.3"
serde_json = "1.0.145"

[profile.release]
lto = true
Expand Down
24 changes: 24 additions & 0 deletions doc/fd.1
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,30 @@ Maximum number of arguments to pass to the command given with -X. If the number
greater than the given size, the command given with -X is run again with remaining arguments. A
batch size of zero means there is no limit (default), but note that batching might still happen
due to OS restrictions on the maximum length of command lines.
.TP
.BI "\-\-json "
.RS
Specify JSONL (as known as NDJSON) format to use for the output.

Output fields:

- "path": The file path as a UTF\-8 string.

Note that when the path contains invalid UTF-8 sequences, it is encoded in base64 and stored in the "path_b64" field instead.

- "type": The file type (e.g., "file", "directory").

- "size": The file size in bytes.

- "mode": The file permissions in octal (e.g., 644).

- "modified": The last modification time in ISO 8601 format (e.g., 2000-01-01T12:00:00Z).

- "accessed": The last access time in ISO 8601 format.

- "created": The creation time in ISO 8601 format.
.RE
.TP
.SH PATTERN SYNTAX
The regular expression syntax used by fd is documented here:

Expand Down
18 changes: 18 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,15 @@ pub struct Opts {
)]
search_path: Vec<PathBuf>,

/// Print results in JSONL format.
#[arg(
long,
value_name = "json",
help = "Print results in JSONL format so you can pipe it to tools.",
long_help
)]
pub json: bool,

/// By default, relative paths are prefixed with './' when -x/--exec,
/// -X/--exec-batch, or -0/--print0 are given, to reduce the risk of a
/// path starting with '-' being treated as a command line option. Use
Expand Down Expand Up @@ -825,6 +834,15 @@ pub enum HyperlinkWhen {
Never,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
pub enum OutputFormat {
/// Plain text output (default)
Plain,
/// JSONL (JSON Lines, as known as Newline Delimited JSON) output
#[value(alias = "ndjson")]
Jsonl,
}

// there isn't a derive api for getting grouped values yet,
// so we have to use hand-rolled parsing for exec and exec-batch
pub struct Exec {
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ pub struct Config {

/// Whether or not to use hyperlinks on paths
pub hyperlink: bool,

/// Whether to print results in JSONL format
pub jsonl: bool,
}

impl Config {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
actual_path_separator,
max_results: opts.max_results(),
strip_cwd_prefix: opts.strip_cwd_prefix(|| !(opts.null_separator || has_command)),
jsonl: opts.json,
})
}

Expand Down
Loading