@@ -222,3 +222,49 @@ def get_users_module(google_ads_client: GoogleAdsClient, customer_id: Optional[s
222222 for field_path_element in error .location .field_path_elements :
223223 print (f"\t \t On field: { field_path_element .field_name } " )
224224 sys .exit (1 )
225+
226+
227+ def main (customer_id_override : Optional [str ] = None ):
228+ """Main function to run the analyzer.
229+
230+ Args:
231+ customer_id_override: Allows bypassing argparse for testing.
232+ """
233+ parser = argparse .ArgumentParser (
234+ description = "This analyzer will display the account info "
235+ "according to the input."
236+ )
237+ parser .add_argument (
238+ "-c" ,
239+ "--customer_id" ,
240+ type = str ,
241+ required = False ,
242+ help = "The Google Ads customer ID." ,
243+ )
244+ args = parser .parse_args ()
245+
246+ # Use customer_id_override if provided, else use parsed args
247+ effective_customer_id = customer_id_override if customer_id_override is not None else args .customer_id
248+
249+ try :
250+ # GoogleAdsClient will read the google-ads.yaml configuration file in
251+ # the home directory if none is specified.
252+ googleads_client = GoogleAdsClient .load_from_storage ()
253+ account_hierarchy_module (googleads_client , effective_customer_id )
254+ get_users_module (googleads_client , effective_customer_id )
255+ except GoogleAdsException as ex :
256+ print (
257+ f'Request with ID "{ ex .request_id } " failed with status '
258+ f'"{ ex .error .code ().name } " '
259+ )
260+ print (f"And includes the following errors:" )
261+ for error in ex .failure .errors :
262+ print (f'\t Error with message "{ error .message } ".' )
263+ if error .location :
264+ for field_path_element in error .location .field_path_elements :
265+ print (f"\t \t On field: { field_path_element .field_name } " )
266+ sys .exit (1 )
267+
268+
269+ if __name__ == "__main__" :
270+ main ()
0 commit comments