Skip to content

Commit

Permalink
Allow -c arg to specify configuration file, #28
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed May 26, 2016
1 parent ed3be6a commit 553d7c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions vcspull/cli.py
Expand Up @@ -71,8 +71,14 @@ def cli(log_level):
@click.argument('repo_terms', nargs=-1)
@click.option('--run-async', '-a', is_flag=True,
help='Run repo syncing concurrently (experimental)')
def update(repo_terms, run_async):
configs = load_configs(find_config_files(include_home=True))
@click.option('config', '-c', type=click.Path(exists=True),
help='Specify config')
def update(repo_terms, run_async, config):
print(config)
if config:
configs = load_configs([config])
else:
configs = load_configs(find_config_files(include_home=True))
found_repos = []

if repo_terms:
Expand Down Expand Up @@ -112,8 +118,6 @@ def clamp(n, _min, _max):


def update_repo(repo_dict):
if 'url' not in repo_dict: # normalize vcs/repo key
repo_dict['url'] = repo_dict['repo']
r = create_repo(**repo_dict)
log.debug('%s' % r)
r.update_repo()
Expand Down
5 changes: 3 additions & 2 deletions vcspull/config.py
Expand Up @@ -31,9 +31,10 @@ def expand_dir(_dir, cwd=os.getcwd()):
:type dir: string
:rtype; string
"""
_dir = os.path.expanduser(os.path.expandvars(_dir))
if not os.path.isabs(_dir):
_dir = os.path.normpath(os.path.join(cwd, _dir))
return os.path.expanduser(os.path.expandvars(_dir))
return _dir


def extract_repos(config, cwd=os.getcwd()):
Expand Down Expand Up @@ -64,7 +65,7 @@ def extract_repos(config, cwd=os.getcwd()):
'''

if isinstance(repo_data, string_types):
conf['url'] = repo_data, cwd
conf['url'] = repo_data
else:
conf = update_dict(conf, repo_data)

Expand Down
2 changes: 1 addition & 1 deletion vcspull/repo/__init__.py
Expand Up @@ -29,7 +29,7 @@
logger.addHandler(channel)


def create_repo(url, *args, **kwargs):
def create_repo(url, **kwargs):
r"""Return object with base class :class:`BaseRepo` depending on url.
Return instance of :class:`vcspull.repo.svn.SubversionRepo`,
Expand Down

0 comments on commit 553d7c2

Please sign in to comment.