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

ExecForEach #22

Closed
bitfield opened this issue Jul 16, 2019 · 5 comments · Fixed by #44
Closed

ExecForEach #22

bitfield opened this issue Jul 16, 2019 · 5 comments · Fixed by #44
Labels
help wanted Extra attention is needed

Comments

@bitfield
Copy link
Owner

Equivalent to shell xargs. For example, this use case: https://gist.github.com/Skraelingjar/9aabc58aa26f5b814411e69d67b342fe

@bitfield bitfield added the help wanted Extra attention is needed label Aug 10, 2019
@gagneet
Copy link

gagneet commented Oct 1, 2019

Would like to help out on this.

@bitfield
Copy link
Owner Author

bitfield commented Oct 7, 2019

Great! Thanks @gagneet. One thing you could do to get the ball rolling is to write a short script program, which assumes the existence of ExecForEach, or whatever we decide to name it, along the lines of the linked use case. Once we're happy with the design, we can then write a test for it.

@mainawycliffe
Copy link
Contributor

I am thinking the func would look roughly something like this:

func (p *Pipe) Xargs(cmd ...string) *Pipe {
	// do something with the output of the previous command
}

or

func (p *Pipe) Xargs(cmd string) *Pipe {
	// do something with the output of the previous command
}

This would take a Pipe and use its output to perform more commands. I am still thinking through, as I look to find more scenarios that the Xargs commands can be used in.

@mainawycliffe
Copy link
Contributor

@bitfield what do you think?

@bitfield
Copy link
Owner Author

I think using ExecForEach should be more or less exactly like using Exec(), but with the addition of a placeholder value in the supplied command. In fact, why don't we use Go template syntax, which is even more powerful?

script.ListFiles("*.php").ExecForEach("php {{ . }}").Stdout()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants