Coder Social home page Coder Social logo

Comments (6)

muesli avatar muesli commented on May 17, 2024 3

I understand where you're coming from, but I wonder if that isn't less intuitive behavior 🤔

from vhs.

spenserblack avatar spenserblack commented on May 17, 2024

A new keyword definitely shouldn't be added without careful consideration, but what do you think about OutputRelative or something similar?

While it's definitely far more common for paths to be relative to the directory that the process is executed in, not the current file, many tools will have some way to get the file's directory (dirname $0 in Bash, __dir__ in Ruby, etc.). Not arguing for that added complexity, but I'm just saying that there's almost always some way to build paths relative to the currently interpreted file.

I should note that my initial issue is actually that vhs new tape.tape doesn't work immediately unless I either create an examples/ directory or change the path in the new tape. I think it's a bit awkward that vhs new tape.tape might not be enough to be a runnable file, and an additional step might be required. This proposal is inspired by that, as I was thinking of a way to allow examples/demo.tape to continue to work as both an example in this repo and as the source for the new command, and allow the newly created tape to always work without additional steps.

from vhs.

spenserblack avatar spenserblack commented on May 17, 2024

I'll note that, while checking out behavior, my initial assumption was that output.gif would be relative to the current directory, and ./output.gif would be relative to the file's directory. Not sure how common that assumption is, though.

from vhs.

rm-dr avatar rm-dr commented on May 17, 2024

It isn't possible to get a relative output file if vhs gets input through stdin (like vhs < path.tape), since vhs doesn't "see" that path at all. Tapes with relative outputs must be loaded as an argument, like vhs path.tape.

Here are a few thoughts:

  • Relative paths will be very helpful if we add an Include keyword, or another feature that pulls extra files. Those are input files, though, not output files.
  • Relative output paths would be pretty counterintuitive. Maybe a cli argument, like --output-relative? A .tape keyword wouldn't really make sense, because we can't get relative output if we load the file through stdin.

As for vhs new, we'd better fix the fact that the file it creates doesn't work. We could do this by putting relative paths in all the demo files, and cding into the examples directories before giving them to vhs.

from vhs.

spenserblack avatar spenserblack commented on May 17, 2024
  • Maybe a cli argument, like --output-relative?

An --out-dir or similar argument could be useful (taking some inspiration from TypeScript).

$ cat file.tape
Output "out.gif"
...

$ vhs --out-dir /path/to/context file.tape
$ ls /path/to/context
out.gif ...

This by itself wouldn't resolve the new tape not working out-of-the-box, but maybe that should be a separate issue. But maybe all of the examples could use --out-dir examples instead of all referencing examples/name.format.

from vhs.

spenserblack avatar spenserblack commented on May 17, 2024

because we can't get relative output if we load the file through stdin.

By the way, interpreted languages like Ruby and JavaScript (Node) allow one to reference paths relative to the current file:

require_relative '../path/to/file'
require('../path/to/file')

Both of these languages support interpretation from stdin AFAIK.
Right now I think that --out-dir is a better solution (I'm happy to change the issue title 🙂), but it might be worth looking into what these languages/interpreters do when the code referencing relative paths comes from stdin.

Edit: Just to give further context to how other tools resolve relative paths, Node will interpret paths relative to the current file, but use the working directory if interpreting from stdin. For example

$ echo "console.log('hello, world');" > greet.js
$ echo "require('../greet.js');" > subdir/index.js
$ node subdir/index.js
hello, world
$ node < subdir/index.js
(stacktrace)
$ cd subdir
$ node index.js
hello, world
$ node < index.js
hello, world

from vhs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.