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

target_name order shouldn't matter #173

Open
aappling-usgs opened this issue Aug 31, 2017 · 1 comment
Open

target_name order shouldn't matter #173

aappling-usgs opened this issue Aug 31, 2017 · 1 comment

Comments

@aappling-usgs
Copy link

It seems I can only use target_name in a command if it's the first argument. I would like to be able to use that variable anywhere in a command.

this remake file creates an i.txt file as expected:

target_default: i.txt
targets:
  i.txt :
    command: file.create(target_name, showWarnings=FALSE)
> make()
<  MAKE > i.txt
[ BUILD ] i.txt |  file.create("i.txt", showWarnings = FALSE)

but this one gives an error:

target_default: i.txt
targets:
  i.txt :
    command: file.create(showWarnings=FALSE, target_name)
> make()
<  MAKE > i.txt
[ BUILD ] i.txt |  file.create(showWarnings = "i.txt", target_name)
Error in file.create(showWarnings = "i.txt", target_name) : 
  object 'target_name' not found

(and also my argument showWarnings=FALSE has been altered in the BUILD call)

@jordansread
Copy link

Note that this is possible when your function supports named arguments. In the example above the args to file.create are ..., showWarnings = TRUE. I agree that it would be nice that target_name could be found when unnamed, it does work when you can tie it to an argument name:

target_default: i.txt
targets:
  i.txt:
    command: file.create(target_name, showWarnings=FALSE)

  i2.txt:
    command: file.copy(from = 'i.txt', to = target_name)

works with

remake::make('i2.txt')
<  MAKE > i2.txt
[    OK ] i.txt
[ BUILD ] i2.txt |  file.copy(from = "i.txt", to = "i2.txt")
[  READ ]        |  # loading packages

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