Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use fd as a library? #837

Open
joehillen opened this issue Aug 25, 2021 · 8 comments
Open

Is it possible to use fd as a library? #837

joehillen opened this issue Aug 25, 2021 · 8 comments
Labels

Comments

@joehillen
Copy link

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?

@will459
Copy link
Contributor

will459 commented Aug 28, 2021

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

@tmccombs
Copy link
Collaborator

In particular the ignore crate may be what you want.

@matu3ba
Copy link

matu3ba commented Dec 16, 2021

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).

@sharkdp
Copy link
Owner

sharkdp commented Dec 28, 2021

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.

@AlaaZorkane
Copy link

AlaaZorkane commented Jan 23, 2022

@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.

@sharkdp
Copy link
Owner

sharkdp commented Jan 29, 2022

So what kind of applications would you all like to build with fd-as-a-library?

@peterdelevoryas
Copy link

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.

@tydavis
Copy link

tydavis commented May 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants