@@ -91,52 +91,58 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
9191 parser .add_argument ("--config" , "-c" , help = "Specify config" )
9292 parser .add_argument ("repo_terms" , nargs = "+" , help = "Specify config" )
9393 parser .add_argument (
94- "--exit-on_error" , "-x" , dest = "exit_on_error" , help = "Specify config"
94+ "--exit-on-error" ,
95+ "-x" ,
96+ action = "store_true" ,
97+ dest = "exit_on_error" ,
98+ help = "Specify config" ,
9599 )
96100 return parser
97101
98102
99- def sync (repo_terms , config , exit_on_error : bool ) -> None :
103+ def sync (
104+ repo_terms ,
105+ config ,
106+ exit_on_error : bool ,
107+ parser : argparse .ArgumentParser | None = None ,
108+ ) -> None :
100109 if config :
101110 configs = load_configs ([config ])
102111 else :
103112 configs = load_configs (find_config_files (include_home = True ))
104113 found_repos = []
105114
106- if repo_terms :
107- for repo_term in repo_terms :
108- dir , vcs_url , name = None , None , None
109- if any (repo_term .startswith (n ) for n in ["./" , "/" , "~" , "$HOME" ]):
110- dir = repo_term
111- elif any (repo_term .startswith (n ) for n in ["http" , "git" , "svn" , "hg" ]):
112- vcs_url = repo_term
113- else :
114- name = repo_term
115-
116- # collect the repos from the config files
117- found = filter_repos (configs , dir = dir , vcs_url = vcs_url , name = name )
118- if len (found ) == 0 :
119- click .echo (NO_REPOS_FOR_TERM_MSG .format (name = name ))
120- found_repos .extend (
121- filter_repos (configs , dir = dir , vcs_url = vcs_url , name = name )
122- )
123- else :
124- click .echo (ctx .get_help (), color = ctx .color )
125- ctx .exit ()
115+ for repo_term in repo_terms :
116+ dir , vcs_url , name = None , None , None
117+ if any (repo_term .startswith (n ) for n in ["./" , "/" , "~" , "$HOME" ]):
118+ dir = repo_term
119+ elif any (repo_term .startswith (n ) for n in ["http" , "git" , "svn" , "hg" ]):
120+ vcs_url = repo_term
121+ else :
122+ name = repo_term
123+
124+ # collect the repos from the config files
125+ found = filter_repos (configs , dir = dir , vcs_url = vcs_url , name = name )
126+ if len (found ) == 0 :
127+ print (NO_REPOS_FOR_TERM_MSG .format (name = name ))
128+ found_repos .extend (filter_repos (configs , dir = dir , vcs_url = vcs_url , name = name ))
126129
127130 for repo in found_repos :
128131 try :
129132 update_repo (repo )
130133 except Exception :
131- click . echo (
134+ print (
132135 f'Failed syncing { repo .get ("name" )} ' ,
133136 )
134137 if log .isEnabledFor (logging .DEBUG ):
135138 import traceback
136139
137140 traceback .print_exc ()
138141 if exit_on_error :
139- raise click .ClickException (EXIT_ON_ERROR_MSG )
142+ if parser is not None :
143+ parser .exit (status = 1 , message = EXIT_ON_ERROR_MSG )
144+ else :
145+ raise SystemExit (EXIT_ON_ERROR_MSG )
140146
141147
142148def progress_cb (output , timestamp ):
0 commit comments