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

Use #run to send multiline arguments #770

Open
jensljungblad opened this issue Jan 18, 2022 · 1 comment
Open

Use #run to send multiline arguments #770

jensljungblad opened this issue Jan 18, 2022 · 1 comment

Comments

@jensljungblad
Copy link

Ran into a problem when converting a Ruby script to Thor.

With Ruby's system method, you can easily pass arguments that contain line-breaks:

body = <<-BODY.strip_heredoc
  String that
  spans multiple
  lines
BODY

# This works:
system("gh", "pr", "create", "--base", "master", "--title", title, "--body", body)

# Using Thor's `run` method does not:
run("gh pr create --base master --title #{title} --body #{body}")

Is there any way to use the run method in this type of scenario?

@dorner
Copy link

dorner commented Jan 19, 2022

Not sure - it looks like Thor uses system to run this command: https://github.com/rails/thor/blob/main/lib/thor/actions.rb#L248

Maybe try fiddling with this and see if you can come up with a PR to fix?

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

No branches or pull requests

2 participants