diff --git a/dotbot/cli.py b/dotbot/cli.py index d77ab42..3ad5345 100644 --- a/dotbot/cli.py +++ b/dotbot/cli.py @@ -17,6 +17,8 @@ def add_options(parser): parser.add_argument('-d', '--base-directory', nargs=1, dest='base_directory', help='execute commands from within BASEDIR', metavar='BASEDIR', required=True) + parser.add_argument('-r', '--no-realpath-base', action='store_false', + dest='base_directory_real_path', help='Do not eliminate symbolic links encountered in BASEDIR') parser.add_argument('-c', '--config-file', nargs=1, dest='config_file', help='run commands given in CONFIGFILE', metavar='CONFIGFILE', required=True) @@ -58,7 +60,7 @@ def main(): tasks = read_config(options.config_file[0]) if not isinstance(tasks, list): raise ReadingError('Configuration file must be a list of tasks') - dispatcher = Dispatcher(options.base_directory[0]) + dispatcher = Dispatcher(options.base_directory[0], options.base_directory_real_path) success = dispatcher.dispatch(tasks) if success: log.info('\n==> All tasks executed successfully') diff --git a/dotbot/dispatcher.py b/dotbot/dispatcher.py index d1a4f95..c412b8d 100644 --- a/dotbot/dispatcher.py +++ b/dotbot/dispatcher.py @@ -4,14 +4,16 @@ from .messenger import Messenger from .context import Context class Dispatcher(object): - def __init__(self, base_directory): + def __init__(self, base_directory, base_directory_real_path): self._log = Messenger() - self._setup_context(base_directory) + self._setup_context(base_directory, base_directory_real_path) self._load_plugins() - def _setup_context(self, base_directory): - path = os.path.abspath(os.path.realpath( - os.path.expanduser(base_directory))) + def _setup_context(self, base_directory, base_directory_real_path): + path = os.path.abspath( + os.path.expanduser(base_directory)) + if base_directory_real_path: + path = os.path.realpath(path) if not os.path.exists(path): raise DispatchError('Nonexistent base directory') self._context = Context(path)