diff options
author | Anish Athalye <me@anishathalye.com> | 2018-05-24 12:00:13 -0400 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2018-05-24 12:57:49 -0400 |
commit | c3f271481aa7740e54342b663dce0e1a1306f5f0 (patch) | |
tree | aaad4327ea97dd682a6803d014beeb2456274f2c /dotbot | |
parent | 2f4cc0d9cb70235e7c5820dc4e7dd89b1d375fb5 (diff) |
Fix handling of base directory
Prior to this patch, Dotbot was relying on running with the base
directory being the current working directory. In practice, it was
relying on the install shim to set up this context. It makes more sense
sense to actually execute `chdir()` within Dotbot itself, rather than
relying on the install shim to do so.
Diffstat (limited to 'dotbot')
-rw-r--r-- | dotbot/cli.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/dotbot/cli.py b/dotbot/cli.py index d77ab42..8febb26 100644 --- a/dotbot/cli.py +++ b/dotbot/cli.py @@ -14,10 +14,10 @@ def add_options(parser): help='suppress most output') parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help='enable verbose output') - parser.add_argument('-d', '--base-directory', nargs=1, + parser.add_argument('-d', '--base-directory', dest='base_directory', help='execute commands from within BASEDIR', metavar='BASEDIR', required=True) - parser.add_argument('-c', '--config-file', nargs=1, dest='config_file', + parser.add_argument('-c', '--config-file', dest='config_file', help='run commands given in CONFIGFILE', metavar='CONFIGFILE', required=True) parser.add_argument('-p', '--plugin', action='append', dest='plugins', default=[], @@ -55,10 +55,11 @@ def main(): for plugin_path in plugin_paths: abspath = os.path.abspath(plugin_path) module.load(abspath) - tasks = read_config(options.config_file[0]) + tasks = read_config(options.config_file) if not isinstance(tasks, list): raise ReadingError('Configuration file must be a list of tasks') - dispatcher = Dispatcher(options.base_directory[0]) + os.chdir(options.base_directory) + dispatcher = Dispatcher(options.base_directory) success = dispatcher.dispatch(tasks) if success: log.info('\n==> All tasks executed successfully') |