File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ def test_main_help(capsys: CaptureFixture[str], options: str) -> None:
133
133
"--theme THEME, -t THEME" ,
134
134
"-h, --help" ,
135
135
"-d, --debug" ,
136
+ "-o, --list-organizations" ,
136
137
"--list-themes" ,
137
138
"--profile" ,
138
139
"--config-file CONFIG_FILE, -c CONFIG_FILE" ,
Original file line number Diff line number Diff line change @@ -150,6 +150,12 @@ def parse_args(argv: List[str]) -> argparse.Namespace:
150
150
help = "config file downloaded from your zulip "
151
151
"organization (default: ~/zuliprc)" ,
152
152
)
153
+ parser .add_argument (
154
+ "-o" ,
155
+ "--list-organizations" ,
156
+ action = "store_true" ,
157
+ help = "list all the organizations that you have configurations for, and exit" ,
158
+ )
153
159
parser .add_argument (
154
160
"--theme" ,
155
161
"-t" ,
@@ -455,6 +461,16 @@ def list_themes() -> str:
455
461
)
456
462
457
463
464
+ def list_realms () -> str :
465
+ valid_orgs = [
466
+ file .parent .name for file in Path (ZULIP_CONFIG_PATH ).glob ("*/zuliprc" )
467
+ ]
468
+ if len (valid_orgs ) == 0 :
469
+ exit_with_error ("No organizations found in zuliprc config folder." )
470
+ text = "The following organizations are available:\n "
471
+ return text + "\n " .join (valid_orgs )
472
+
473
+
458
474
def path_to_realm_zuliprc (realm_name_prefix : str ) -> str :
459
475
if len (realm_name_prefix ) < 3 :
460
476
exit_with_error ("Organization name prefix must be at least 3 characters long" )
@@ -513,6 +529,10 @@ def main(options: Optional[List[str]] = None) -> None:
513
529
print (f"Zulip Terminal { ZT_VERSION } " )
514
530
sys .exit (0 )
515
531
532
+ if args .list_organizations :
533
+ print (list_realms ())
534
+ sys .exit (0 )
535
+
516
536
if args .list_themes :
517
537
print (list_themes ())
518
538
sys .exit (0 )
You can’t perform that action at this time.
0 commit comments