uutils / findutils

Rust implementation of findutils
MIT License
280 stars 35 forks source link

Implement `-fprintf` #383

Open hanbings opened 1 month ago

hanbings commented 1 month ago

refer: https://www.gnu.org/software/findutils/manual/html_node/find_html/Print-File-Information.html

Action: -fprintf file format
True; like ‘-printf’ but write to file like ‘-fprint’. 
The output file is always created, even if no output is ever sent to it.

-fprint see Print File Name

radhesh1 commented 1 week ago

is print in printer.rs?

hanbings commented 6 days ago

Oh, I'm sorry for overlooking this. -printf has been implemented. thanks :)

radhesh1 commented 6 days ago

Could you point me where because from what I read they seem to have similar implementation

radhesh1 commented 6 days ago

I would to try and improve cuz I want more rust in Debian

cakebaker commented 6 days ago

Could you point me where because from what I read they seem to have similar implementation

Have a look at matchers/printf.rs.

hanbings commented 6 days ago

Could you point me where because from what I read they seem to have similar implementation

Sorry for the late reply.

In simple terms, -fprintf is an implementation of -printf that directs output to a file and -printf is implemented in printf.rs(https://github.com/uutils/findutils/blob/main/src/find/matchers/printf.rs). Here is a detailed description of -fprintf: Print File Name

Some information that might be helpful:

radhesh1 commented 4 days ago

the thing im confused about is

radhesh1 commented 4 days ago

should i make a new file for fprintf or just have a function since most the functionaluity is the same

hanbings commented 4 days ago

should i make a new file for fprintf or just have a function since most the functionaluity is the same

I guess yes, making the modification in the printf.rs file might use less code. For example, add an Option<Path> field to the Printf(https://github.com/uutils/findutils/blob/main/src/find/matchers/printf.rs#L600) structure and switch different outputs in write!() depending on whether Option has data.

What are your thoughts on this? :) @cakebaker