@@ -157,6 +157,12 @@ def parse_args(argv: List[str]) -> argparse.Namespace:
157
157
action = "store_true" ,
158
158
help = "list all the organizations that you have configurations for, and exit" ,
159
159
)
160
+ parser .add_argument (
161
+ "-n" ,
162
+ "--new-organization" ,
163
+ action = "store_true" ,
164
+ help = "login to a new organization" ,
165
+ )
160
166
parser .add_argument (
161
167
"--theme" ,
162
168
"-t" ,
@@ -294,7 +300,7 @@ def get_api_key(realm_url: str) -> Optional[Tuple[str, str, str, str]]:
294
300
return None
295
301
296
302
297
- def fetch_zuliprc (zuliprc_path : str ) -> str :
303
+ def fetch_zuliprc (zuliprc_path : str , new_realm : bool ) -> str :
298
304
supported_locations = [
299
305
ZULIP_CONFIG_PATH ,
300
306
HOME_PATH_ZULIPRC ,
@@ -305,8 +311,13 @@ def fetch_zuliprc(zuliprc_path: str) -> str:
305
311
if zuliprc_path != ""
306
312
else "any of the following locations:\n " + "\n " .join (supported_locations )
307
313
)
314
+ missing_zuliprc_text = (
315
+ ""
316
+ if new_realm
317
+ else f"{ in_color ('red' , f'zuliprc file was not found at { locations_checked } ' )} "
318
+ )
308
319
print (
309
- f"{ in_color ( 'red' , f'zuliprc file was not found at { locations_checked } ' ) } "
320
+ f"{ missing_zuliprc_text } "
310
321
f"\n Please enter your credentials to login into your Zulip organization."
311
322
f"\n "
312
323
f"\n NOTE: The { in_color ('blue' , 'Zulip server URL' )} "
@@ -392,15 +403,21 @@ def check_for_default_zuliprc() -> str:
392
403
return ""
393
404
394
405
395
- def parse_zuliprc (zuliprc_str : str ) -> Tuple [Dict [str , SettingData ], str ]:
406
+ def parse_zuliprc (
407
+ zuliprc_str : str , new_realm : bool
408
+ ) -> Tuple [Dict [str , SettingData ], str ]:
396
409
zuliprc_path = (
397
- check_for_default_zuliprc ()
398
- if zuliprc_str == ""
399
- else path .expanduser (zuliprc_str )
410
+ (
411
+ check_for_default_zuliprc ()
412
+ if zuliprc_str == ""
413
+ else path .expanduser (zuliprc_str )
414
+ )
415
+ if not new_realm
416
+ else ""
400
417
)
401
418
while zuliprc_path == "" or not path .exists (zuliprc_path ):
402
419
try :
403
- zuliprc_path = fetch_zuliprc (zuliprc_path )
420
+ zuliprc_path = fetch_zuliprc (zuliprc_path , new_realm )
404
421
# Invalid user inputs (e.g. pressing arrow keys) may cause ValueError
405
422
except (OSError , ValueError ):
406
423
# Remove zuliprc file if created.
@@ -559,7 +576,7 @@ def main(options: Optional[List[str]] = None) -> None:
559
576
)
560
577
561
578
try :
562
- zterm , zuliprc_path = parse_zuliprc (zuliprc_path )
579
+ zterm , zuliprc_path = parse_zuliprc (zuliprc_path , args . new_organization )
563
580
564
581
### Validate footlinks settings (not from command line)
565
582
if (
0 commit comments