diff --git a/mepo.d/cmdline/parser.py b/mepo.d/cmdline/parser.py index 3a3d3b67..e94d1efa 100644 --- a/mepo.d/cmdline/parser.py +++ b/mepo.d/cmdline/parser.py @@ -78,8 +78,8 @@ def __clone(self): '--config', metavar = 'config-file', nargs = '?', - default = 'components.yaml', - help = 'Configuration file (ignored if init already called, default: %(default)s)') + default = None, + help = 'Configuration file (ignored if init already called)') def __list(self): listcomps = self.subparsers.add_parser( diff --git a/mepo.d/command/clone/clone.py b/mepo.d/command/clone/clone.py index 901624b0..ac418fff 100644 --- a/mepo.d/command/clone/clone.py +++ b/mepo.d/command/clone/clone.py @@ -16,8 +16,14 @@ def run(args): # If you pass in a config, with clone, it could be outside the repo. # So use the full path + passed_in_config = False if args.config: + passed_in_config = True args.config = os.path.abspath(args.config) + else: + # If we don't pass in a config, we need to "reset" the arg to the + # default name because we pass args to mepo_init + args.config = 'components.yaml' if args.repo_url: p = urlparse(args.repo_url) @@ -35,9 +41,12 @@ def run(args): local_clone(args.repo_url,args.branch) os.chdir(git_url_directory) - # Copy the new file into the repo - if args.config: - shutil.copy(args.config,os.getcwd()) + # Copy the new file into the repo only if we pass it in + if passed_in_config: + try: + shutil.copy(args.config,os.getcwd()) + except shutil.SameFileError as e: + pass # This tries to read the state and if not, calls init, # loops back, and reads the state