rust-crates / ergo_fs

ergonomic filesystem operations in rust
https://docs.rs/ergo_fs
Other
7 stars 0 forks source link

add shellexpand and glob #1

Closed vitiral closed 6 years ago

vitiral commented 6 years ago

Glob

Add functions glob and glob_with which are identical to the ones in the glob crate except they return an iterator of PathType objects instead of simple paths.

This should really have https://github.com/rust-lang-nursery/glob/issues/64 implemented so that GlobError is coercible into io::Error. GlobError already provides excellent context.

Shellexpand

This will mainly involve exporting the shellexpand module, but the trait mentioned in https://github.com/netvl/shellexpand/issues/2 would probably improve the ergonomics.

I have read through the shellexpand source code and I think it has ergonomic error messages.

vitiral commented 6 years ago

@killercup thoughts?

killercup commented 6 years ago

FYI https://twitter.com/killercup/status/957691964694188033

Am 29.01.2018 um 02:52 schrieb Garrett Berg notifications@github.com:

@killercup thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

vitiral commented 6 years ago

I can do that. You want to include ergo_fs into quicli?

On Jan 29, 2018 2:46 AM, "Pascal Hertleif" notifications@github.com wrote:

FYI https://twitter.com/killercup/status/957691964694188033

Am 29.01.2018 um 02:52 schrieb Garrett Berg notifications@github.com:

@killercup thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-crates/ergo_fs/issues/1#issuecomment-361191870, or mute the thread https://github.com/notifications/unsubscribe-auth/AFVCy6nDIDBHrAJMK2zpxM-QBQXyXKZlks5tPZN6gaJpZM4Rv90l .

killercup commented 6 years ago

@gilnaa is already working on it.

Not sure if I want to include (parts of) it in quicli or I use a subset of its re-exports and add documentation about where to find more.

vitiral commented 6 years ago

So I'm thinking of doing PathType::glob, PathFile::glob, PathDir::glob

(and also the same for glob_with)

This will give the choice of what types they want. Thoughts?

vitiral commented 6 years ago

Ok, I think that was the wrong approach.

Instead on my GlobPaths object I'm going to have a files() method that only returns files. I think that is the right approach.

This could honestly be added to the glob crate as well. I think I'm going to add a PR.

Update: see issue https://github.com/rust-lang-nursery/glob/issues/65

vitiral commented 6 years ago

done

vitiral commented 6 years ago

@killercup I recommend not exporting ergo_fs wholesale yet, as I think I'm going to remove the std_prelude export and replace it with only Path, PathBuf, Read and Write.