Skip to content
Open
Show file tree
Hide file tree
Changes from 20 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 `--yaml` flag for YAML format output.

## Bugfixes

Expand Down
50 changes: 46 additions & 4 deletions Cargo.lock

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

20 changes: 10 additions & 10 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= "2021"
edition = "2021"
rust-version = "1.77.2"

[badges.appveyor]
Expand Down Expand Up @@ -49,6 +43,7 @@ jiff = "0.2.14"
# For now, pin the `home` crate to less than 0.5.11, to ensure it works on older versions of rust
# TODO: when we upgrade past rust 1.85, remove this dependency
home = "=0.5.9"
base64 = "0.22.1"

[dependencies.clap]
version = "4.5.48"
Expand All @@ -60,7 +55,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 @@ -71,13 +70,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
17 changes: 17 additions & 0 deletions doc/fd.1
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,23 @@ 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 "\-\-output "
Specify a structured format to use for the output. The value can be plain (default), json, jsonl, or
yaml.

Currently, the default is "plain", and if the option is used without an argument "plain"
is used. The available options are:
.RS
.IP plain
Output the results as plain text (default).
.IP json
Output the results as a JSON array.
.IP jsonl
Output the results as JSON Lines (as known as NDJSON).
.IP yaml
Output the results as YAML.
.RE
.SH PATTERN SYNTAX
The regular expression syntax used by fd is documented here:

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

/// Print results in a certain format so you can pipe it to tools.
#[arg(
long,
value_name = "output",
value_enum,
default_value_t = OutputFormat::Plain,
conflicts_with("format"),
conflicts_with("list_details"),
help = "Print results in a certain format so you can pipe it to tools."
)]
pub output: OutputFormat,

/// 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 @@ -824,6 +836,20 @@ pub enum HyperlinkWhen {
Never,
}

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

// 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
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{path::PathBuf, sync::Arc, time::Duration};
use lscolors::LsColors;
use regex::bytes::RegexSet;

use crate::cli::OutputFormat;
use crate::exec::CommandSet;
use crate::filetypes::FileTypes;
#[cfg(unix)]
Expand Down Expand Up @@ -130,6 +131,9 @@ pub struct Config {

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

/// The output format to use
pub output: OutputFormat,
}

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)),
output: opts.output,
})
}

Expand Down
Loading
Loading