The goal of dmc is to provide a "file-sytem-like" command line api for salesforce.com metadata deploys and retrieves. The original goal was to allow simple globbing patterns to select the metadata to deploy as well as the metadata to retrieve. It was looking something like this...
Deploys:
$ dmc deploy src/classes/*
$ dmc deploy src/**/*
$ dmc deploy src/pages/Module* src/classes/Module*
Retrieves (the exact same patterns):
$ dmc retrieve src/classes/*
$ dmc retrieve src/**/*
$ dmc deploy src/pages/Module* src/classes/Module*
When you pass a raw globbing pattern as a command line argument, most *nix
shells will glob that pattern for you, match the files, and pass the
matched files to your program. For dmc
this works most of the time
for deploys, and it kind a deal-killer for retrieves.
When I say it works most of the time for deploys, that's because the files
that you want to deploy must actually be present in the src directory. Each
shell handles globbing differently though. For example, you'd really want
a glob like src/**/*
to match all files and have that pattern traverse
through subdirectories using globstar. However, globstar is not a default
in bash so you'd have to modify your .bash_profile
or .bashrc
to turn
this on by default, otherwise, you'll only match directories that are a direct
child of src
and no subdirectories would be expanded.
The globbing issue is a deal killer for retrieves. If we let the shell environment
process that glob pattern, we'd only ever be able to retrieve the files that are
currently in our local src directory. We want to be able to do src/**/*
here
if we wanted to get all metadata for an org. dmc
really needs to take the raw
globbing pattern and handle it completely differently. I have some code that would
take the pattern and process it over a retrieved index of metadata.
Here is where I need some help. There are several ways to make this work and I'd like to know what you think would be the best solution. I'm also open to other solutions.
Again the goal is to keep the deploy and retrieve api feeling very similar. Since raw globbing patterns won't really work at all for retrieves, one simple solution is to enforce that globs are passed to dmc in a way that they won't be expanded by the shell. Here are some possibilities.
This is the simplest solution as this tells the shell not to process the glob.
This would even mean that you could still use un-quoted glob patterns but the
user would just need to understand how their current shell would handle it. dmc
still treats the arguments as globs even if the shell has already expanded them.
$ dmc deploy 'src/**/*'
$ dmc deploy 'src/classes/* src/pages/*'
$ dmc retrieve 'src/**/*'
$ dmc retrieve 'src/classes/*' 'src/pages/*'
This is more verbose, but would feel very familiar to javascript developers
$ dmc deploy ['src/**/*']
$ dmc deploy ['src/classes/*', 'src/pages/*']
$ dmc retrieve ['src/**/*']
$ dmc retrieve ['src/classes/*', 'src/pages/*']
This one sucks but you could just provide setup instructions on how to
alias the dmc
binary to turn off globbing
so that dmc
could just handle it. This would be different for each shell. I also have
no idea how any of this would work in Windows.
Any other ideas here?
+1 for quotes. seems the cleanest and puts the control in your hands.