casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
20.78k stars 454 forks source link

Inherited command with output #1629

Open psyciknz opened 1 year ago

psyciknz commented 1 year ago

I'm trying to write two commands that write out yaml. One to screen, the other to file.

I was hoping the to file could call the to screen and just redirect the output.

newsub channelname showname url:
  @echo
  @echo {{channelname}}:
  @echo '  preset:'
  @echo '    - "tv_show"'
  @echo '    - "only_recent_videos"'
  @echo
  @echo '  overrides:'
  @echo '    # Required to specify for every subscription'
  @echo '    tv_show_name: "{{showname}}"'
  @echo '    url: "{{url}}"'
  @echo '    # Optional'
  @echo '    tv_show_genre: "Cars"'

newsubappend channelname showname url:
  just newsub {{channelname}} {{showname}} {{url}} >> subscription.yaml

But alas

just newsubappend newchanelappend "mynew channel" "http://newurl"
just newsub newchanelappend mynew channel http://newurl >> subscriptions.yaml
error: Justfile does not contain recipe `http://newurl`.
error: Recipe `newsubappend` failed on line 20 with exit code 1
laniakea64 commented 1 year ago

Try

newsubappend channelname showname url:
  just -f {{quote(justfile())}} newsub {{quote(channelname)}} {{quote(showname)}} {{quote(url)}} >> subscription.yaml