qrush / sub

a delicious way to organize programs
http://37signals.com/svn/posts/3264-automating-with-convention-introducing-sub
MIT License
1.74k stars 148 forks source link

Support for files that shouldn't be under version control #18

Closed bradical closed 11 years ago

bradical commented 11 years ago

This is more of a question than an issue, but is the share directory intended for files that may contain machine specific passwords or other files that you wouldn't want to be in git?

If not, do you have a standard way to do this in your own commands?

qrush commented 11 years ago

It's more for "data" files, like configuration, templates, etc, that wouldn't otherwise be executable and in the bin directory. I think putting machine-specific passwords in there and a command in bin to parse that out would be fine.

bradical commented 11 years ago

Thanks for the explanation! Can you explain how putting the command in bin would work? Would this expose the data to all of my sub-commands?

The convention I came up with was to add a /share/<MY_SUB_NAME>/*.properties to my .gitignore and then assume the files are things like mysql.properties.

bradical commented 11 years ago

Does everything in bin get loaded? I put some utility functions in a BASH script in there. Is that the correct way to approach it? Do I need to manually load that script?

bradical commented 11 years ago

FYI, the way I ended up sharing this utility command was by creating a file in libexec called "prop-loader" with a function load-props:

PROPS_FILE=$_CSD_ROOT/share/csd/mysql.properties
load-props() {
if [ ! -f $PROPS_FILE ];
then
  echo "MySQL properties file not found. Please create a file ${PROPS_FILE} with at least a PASSWORD property. You can copy the mysql.properties.default file" >&2
  exit
fi
source $PROPS_FILE
if [ -z "$PASSWORD" ];
then
  echo "Properties file exists but does not contain PASSWORD. Please add a MySQL password to your properties file in ${PROPS_FILE}" >&2
  exit
fi
}