88import logging
99import sys
1010
11- from . import __version__ , configure_logger
11+ from . import __version__
1212from ._config import parse_config_files
1313from ._gh_org import GHorg
14+ from ._helpers import configure_logger , log_progress
1415from ._setup_team import setup_team
1516
1617# Main parser with root-level flags
2627
2728# Common flags, usable for all effective subcommands
2829common_flags = argparse .ArgumentParser (add_help = False ) # No automatic help to avoid duplication
29- common_flags .add_argument ("--debug" , action = "store_true" , help = "Get verbose logging output" )
30+ common_flags .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Get INFO logging output" )
31+ common_flags .add_argument ("-vv" , "--debug" , action = "store_true" , help = "Get DEBUG logging output" )
3032
3133# Sync commands
3234parser_sync = subparsers .add_parser (
@@ -95,14 +97,15 @@ def main():
9597 # Process arguments
9698 args = parser .parse_args ()
9799
98- configure_logger (args .debug )
100+ configure_logger (verbose = args . verbose , debug = args .debug )
99101
100102 # Sync command
101103 if args .command == "sync" :
104+ log_progress ("Preparing..." )
102105 if args .dry :
103106 logging .info ("Dry-run mode activated, will not make any changes at GitHub" )
104107 if args .force :
105- logging .info ("Force mode activated, will make potentially dangerous actions" )
108+ logging .warning ("Force mode activated, will make potentially dangerous actions" )
106109
107110 org = GHorg ()
108111
@@ -129,33 +132,43 @@ def main():
129132 org .ratelimit ()
130133
131134 # Synchronise organisation owners
135+ log_progress ("Synchronising organisation owners..." )
132136 org .sync_org_owners (dry = args .dry , force = args .force )
133137 # Create teams that aren't present at Github yet
138+ log_progress ("Creating missing teams..." )
134139 org .create_missing_teams (dry = args .dry )
135140 # Configure general settings of teams
141+ log_progress ("Configuring team settings..." )
136142 org .sync_current_teams_settings (dry = args .dry )
137143 # Synchronise the team memberships
144+ log_progress ("Synchronising team memberships..." )
138145 org .sync_teams_members (dry = args .dry )
139146 # Report and act on teams that are not configured locally
147+ log_progress ("Checking for unconfigured teams..." )
140148 org .get_unconfigured_teams (
141149 dry = args .dry ,
142150 delete_unconfigured_teams = cfg_app .get ("delete_unconfigured_teams" , False ),
143151 )
144152 # Report and act on organisation members that do not belong to any team
153+ log_progress ("Checking for members without team..." )
145154 org .get_members_without_team (
146155 dry = args .dry ,
147156 remove_members_without_team = cfg_app .get ("remove_members_without_team" , False ),
148157 )
149158 # Synchronise the permissions of teams for all repositories
159+ log_progress ("Synchronising team permissions..." )
150160 org .sync_repo_permissions (dry = args .dry , ignore_archived = args .ignore_archived )
151161 # Remove individual collaborator permissions if they are higher than the one
152162 # from team membership (or if they are in no configured team at all)
163+ log_progress ("Synchronising individual collaborator permissions..." )
153164 org .sync_repo_collaborator_permissions (dry = args .dry )
154165
155166 # Debug output
167+ log_progress ("" ) # clear progress
156168 logging .debug ("Final dataclass:\n %s" , org .pretty_print_dataclass ())
157169 org .ratelimit ()
158170
171+ # Print changes
159172 org .stats .print_changes (
160173 orgname = cfg_org .get ("org_name" , "" ), output = args .output , dry = args .dry
161174 )
0 commit comments