@@ -156,6 +156,12 @@ def parse_args(argv: List[str]) -> argparse.Namespace:
156
156
action = "store_true" ,
157
157
help = "list all the organizations that you have configurations for, and exit" ,
158
158
)
159
+ parser .add_argument (
160
+ "-n" ,
161
+ "--new-organization" ,
162
+ action = "store_true" ,
163
+ help = "login to a new organization" ,
164
+ )
159
165
parser .add_argument (
160
166
"--theme" ,
161
167
"-t" ,
@@ -293,15 +299,20 @@ def get_api_key(realm_url: str) -> Optional[Tuple[str, str, str, str]]:
293
299
return None
294
300
295
301
296
- def fetch_zuliprc (zuliprc_path : str ) -> str :
302
+ def fetch_zuliprc (zuliprc_path : str , new_realm : bool ) -> str :
297
303
locations_checked = (
298
304
zuliprc_path
299
305
if zuliprc_path != ""
300
306
else f"any of the following locations: "
301
307
f"{ DOWNLOADED_PATH_ZULIPRC } or { ZULIP_CONFIG_PATH } or { HOME_PATH_ZULIPRC } "
302
308
)
309
+ missing_zuliprc_text = (
310
+ ""
311
+ if new_realm
312
+ else f"{ in_color ('red' , f'zuliprc file was not found at { locations_checked } ' )} "
313
+ )
303
314
print (
304
- f"{ in_color ( 'red' , f'zuliprc file was not found at { locations_checked } ' ) } "
315
+ f"{ missing_zuliprc_text } "
305
316
f"\n Please enter your credentials to login into your Zulip organization."
306
317
f"\n "
307
318
f"\n NOTE: The { in_color ('blue' , 'Zulip server URL' )} "
@@ -387,15 +398,21 @@ def check_for_default_zuliprc() -> str:
387
398
return ""
388
399
389
400
390
- def parse_zuliprc (zuliprc_str : str ) -> Tuple [Dict [str , SettingData ], str ]:
401
+ def parse_zuliprc (
402
+ zuliprc_str : str , new_realm : bool
403
+ ) -> Tuple [Dict [str , SettingData ], str ]:
391
404
zuliprc_path = (
392
- check_for_default_zuliprc ()
393
- if zuliprc_str == ""
394
- else path .expanduser (zuliprc_str )
405
+ (
406
+ check_for_default_zuliprc ()
407
+ if zuliprc_str == ""
408
+ else path .expanduser (zuliprc_str )
409
+ )
410
+ if not new_realm
411
+ else ""
395
412
)
396
413
while zuliprc_path == "" or not path .exists (zuliprc_path ):
397
414
try :
398
- zuliprc_path = fetch_zuliprc (zuliprc_path )
415
+ zuliprc_path = fetch_zuliprc (zuliprc_path , new_realm )
399
416
# Invalid user inputs (e.g. pressing arrow keys) may cause ValueError
400
417
except (OSError , ValueError ):
401
418
# Remove zuliprc file if created.
@@ -552,7 +569,7 @@ def main(options: Optional[List[str]] = None) -> None:
552
569
)
553
570
554
571
try :
555
- zterm , zuliprc_path = parse_zuliprc (zuliprc_path )
572
+ zterm , zuliprc_path = parse_zuliprc (zuliprc_path , args . new_organization )
556
573
557
574
### Validate footlinks settings (not from command line)
558
575
if (
0 commit comments