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

[Enhancement proposal] Replacement Strings #871

Closed
TonioGela opened this issue Jun 13, 2021 · 2 comments · Fixed by #872
Closed

[Enhancement proposal] Replacement Strings #871

TonioGela opened this issue Jun 13, 2021 · 2 comments · Fixed by #872

Comments

@TonioGela
Copy link
Contributor

I think that a feature like GNU parallel's replacement strings would be handy.

I was wondering something like:

foo := "A/B/C.D"

echo {{foo.}}   // A/B/C   (Removes extension)
echo {{foo/}}   // C.D     (Removes the path)
echo {{foo//}}  // A/B     (Keeps the path only)
echo {{foo/.}}  // C       (Removes path and extension)

What do you think @casey?

I'm terribly sorry since I don't know Rust enough to contribute by myself and that's why this is an issue and not a PR. If I'll spot the parser I'll begin to do some test.

@casey
Copy link
Owner

casey commented Jun 13, 2021

I definitely think this could be useful. Just already has some built-in functions, so it would be easy to create new ones that performed these operations:

foo := "A/B/C.D"

echo {{without_extension(foo)}} // A/B/C   (Removes extension)
echo {{file_name(foo)}}         // C.D     (Removes the path)
echo {{directory(foo)}}         // A/B     (Keeps the path only)
echo {{file_stem(foo)}}         // C       (Removes path and extension)

Rust has a bunch of path operations in the standard library which could be used in the implementation, so it wouldn't be necessary to write them from scratch.

@TonioGela
Copy link
Contributor Author

Hmm, sounds interesting, I'll give it a try

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

Successfully merging a pull request may close this issue.

2 participants