robfig / glock

MIT License
230 stars 27 forks source link

sync can now read from stdin like save. #6

Closed joliver closed 10 years ago

joliver commented 10 years ago

I just added the ability for sync to behave like save which can read from stdin. This allows users of this tool to specify their own names to the GLOCKFILE.

robfig commented 10 years ago

What use case are you are trying to fulfill? Do you just want the file named something different?

joliver commented 10 years ago

Exactly. We've got a strict naming convention and this is the perfect tool. By having a "-n" option for sync just like save, it allows user-defined file naming requirements. I was about to write my own tool but then I found yours. The only thing I needed was a custom filename. Otherwise this tool is perfect.

joliver commented 10 years ago

Also the travis failure appears to be because of a missing travis-ci file. I'm using code in this pull request right now without trouble.

robfig commented 10 years ago

I just added the .travis.yml

I wonder if an even better solution for you would be to look for the glockfile name as an environment variable, falling back to GLOCKFILE otherwise?

joliver commented 10 years ago

If you want to support a variable GLOCKFILE filename, then there's four ways I can see this working:

  1. standard in
  2. command line argument, e.g. -f custom-file.txt
  3. environment variable, e.g. GLOCKFILE=custom-file.txt
  4. configuration file (which itself imposes a convention)

Of the four options, the standard in method is the least heavy handed, imposes the least amount of cognitive overhead, and most closely aligns with the Unix philosophy. Following that, a command-line argument with something like --file or -f is the next best option.

Beyond the reasons above, I also wanted to follow the previously established convention set forth in your library of using -n for standard in/out.

joliver commented 10 years ago

Would you like to pull the latest and merge my changes?

robfig commented 10 years ago

Thanks, I ended up doing it a little bit differently -- https://github.com/robfig/glock/commit/30723574b54030cef8a13e672ce287f29c59f369

Let me know how it works for you