fd
fd copied to clipboard
Is it possible to use fd as a library?
Pardon my ignorance. I'm new to rust.
I'd like to use fd's features in the program I'm writing. Is it possible to use a bin crate as a library? Is there some special I would need to do to make it work?
As it currently exists not really. The Cargo.toml only defines a [bin] section and everything in the src/ directory exists within that binary. If some component of the binary was to be broken out into it's own workspace it could then be used as a library, pending approval from the maintainer. What is it you were looking to do? It is possible that the utility you are looking for is provided by a dependency to fd or otherwise exists on crates.io
In particular the ignore
crate may be what you want.
I would suggest against that, since fd
has no specification for the output (yet).
For example #861 changed the output formatting, which broke my simple dotfile skeleton.
I would wait at least until #760 is fixed for all command line options. Then try to convince @sharkdp to refactor it into a lib and cli frontend. See this article for accurate information (also linked in the issue).
For example #861 changed the output formatting, which broke my simple dotfile skeleton.
Sorry for that. Maybe that should have been pointed out as a breaking change in the release notes (https://github.com/sharkdp/fd/releases/tag/v8.3.0)
Then try to convince @sharkdp to refactor it into a lib and cli frontend.
I know that this could be valuable for others. I have done the same (split into bin+library) with my command-line tools bat
, pastel
, diskus
and hexyl
. The main problem is that it causes much more maintenance. Because now the interface between the library and the CLI frontend becomes a public API that needs to be carefully designed, should not have breaking changes too often, etc.
Given that the ignore
crate provides a core part of fd
already, I would indeed need some convincing arguments (like someone stepping up as a maintainer for the library part in the future) to consider such a move for fd
, as this sounds like a lot of work.
@sharkdp not really a very convincing argument but ignore
's frontend is relatively low-level and annoying to use than what would be an fd
's frontend if all of the later's args were to be ~~converted~~ moved to a builder interface.
So what kind of applications would you all like to build with fd-as-a-library?
So what kind of applications would you all like to build with fd-as-a-library?
Finding dependencies in some Linux environment automatically for development tools. Like finding QEMU and images to boot automatically, so the user doesn't have to constantly specify paths to things in a large build directory (Yocto is like this). I could just use the stdout though.
So what kind of applications would you all like to build with fd-as-a-library?
I'm writing a dev-tool that needs to scan an entire filesystem for git repos, then store their config data. Subsequent runs pull from the stored file and either clone-and-set-up the repos again with all remotes & branches, or pick up new repositories and add them to the config.