|
41 | 41 | • Other systems: https://www.portaudio.com/""" |
42 | 42 |
|
43 | 43 | PLAYER_APP_SENTINEL = "player" |
44 | | -EXPLICIT_APPS = frozenset({PLAYER_APP_SENTINEL, "daemon", "serve"}) |
| 44 | +EXPLICIT_APPS = frozenset( |
| 45 | + {PLAYER_APP_SENTINEL, "daemon", "serve", "audio-devices", "servers", "clients"} |
| 46 | +) |
45 | 47 | TOP_LEVEL_ACTIONS = frozenset({"-h", "--help", "--version"}) |
46 | 48 |
|
47 | 49 |
|
@@ -92,6 +94,7 @@ def list_audio_devices() -> None: |
92 | 94 | ) |
93 | 95 | if devices: |
94 | 96 | print(f"\nTo select an audio device:\n sendspin --audio-device {devices[0].index}") |
| 97 | + print(f" sendspin daemon --audio-device {devices[0].index}") |
95 | 98 |
|
96 | 99 | if sys.platform.startswith("linux"): |
97 | 100 | alsa_devices = list_alsa_devices() |
@@ -143,7 +146,7 @@ def _add_player_runtime_options(target: ArgumentTarget, *, suppress_defaults: bo |
143 | 146 | help=( |
144 | 147 | "Audio output device by index (e.g., 0, 1, 2), name prefix (e.g., 'MacBook'), " |
145 | 148 | "or raw ALSA device name (e.g., 'dmixer', 'olohuone') for plugin devices like dmix. " |
146 | | - "Use --list-audio-devices to see enumerated devices." |
| 149 | + "Use 'sendspin audio-devices list' to see enumerated devices." |
147 | 150 | ), |
148 | 151 | ) |
149 | 152 | target.add_argument( |
@@ -206,19 +209,19 @@ def _add_player_actions(target: ArgumentTarget, *, suppress_defaults: bool = Fal |
206 | 209 | "--list-audio-devices", |
207 | 210 | action="store_true", |
208 | 211 | default=argparse.SUPPRESS if suppress_defaults else False, |
209 | | - help="List available audio output devices and exit", |
| 212 | + help="(deprecated: use 'sendspin audio-devices list') List audio devices and exit", |
210 | 213 | ) |
211 | 214 | target.add_argument( |
212 | 215 | "--list-servers", |
213 | 216 | action="store_true", |
214 | 217 | default=argparse.SUPPRESS if suppress_defaults else False, |
215 | | - help="Discover and list available Sendspin servers on the network", |
| 218 | + help="(deprecated: use 'sendspin servers list') List Sendspin servers and exit", |
216 | 219 | ) |
217 | 220 | target.add_argument( |
218 | 221 | "--list-clients", |
219 | 222 | action="store_true", |
220 | 223 | default=argparse.SUPPRESS if suppress_defaults else False, |
221 | | - help="Discover and list available Sendspin clients on the network", |
| 224 | + help="(deprecated: use 'sendspin clients list') List Sendspin clients and exit", |
222 | 225 | ) |
223 | 226 | target.add_argument( |
224 | 227 | "--headless", |
@@ -357,7 +360,7 @@ def _build_parser() -> argparse.ArgumentParser: |
357 | 360 | default=None, |
358 | 361 | help=( |
359 | 362 | "Audio output device by index (e.g., 0, 1, 2) or name prefix (e.g., 'MacBook'). " |
360 | | - "Use --list-audio-devices to see available devices." |
| 363 | + "Use 'sendspin audio-devices list' to see available devices." |
361 | 364 | ), |
362 | 365 | ) |
363 | 366 | daemon_parser.add_argument( |
@@ -418,6 +421,57 @@ def _build_parser() -> argparse.ArgumentParser: |
418 | 421 | help="Product name reported in the client hello (defaults to auto-detected OS/platform name)", |
419 | 422 | ) |
420 | 423 |
|
| 424 | + # audio-devices subcommand |
| 425 | + audio_devices_parser = subparsers.add_parser( |
| 426 | + "audio-devices", |
| 427 | + help="Audio device utilities", |
| 428 | + description="Audio device utilities.", |
| 429 | + ) |
| 430 | + audio_devices_sub = audio_devices_parser.add_subparsers( |
| 431 | + dest="audio_devices_command", |
| 432 | + title="Commands", |
| 433 | + required=True, |
| 434 | + ) |
| 435 | + audio_devices_sub.add_parser( |
| 436 | + "list", |
| 437 | + help="List available audio output devices", |
| 438 | + description="List all available audio output devices and exit.", |
| 439 | + ) |
| 440 | + |
| 441 | + # servers subcommand |
| 442 | + servers_parser = subparsers.add_parser( |
| 443 | + "servers", |
| 444 | + help="Server discovery utilities", |
| 445 | + description="Server discovery utilities.", |
| 446 | + ) |
| 447 | + servers_sub = servers_parser.add_subparsers( |
| 448 | + dest="servers_command", |
| 449 | + title="Commands", |
| 450 | + required=True, |
| 451 | + ) |
| 452 | + servers_sub.add_parser( |
| 453 | + "list", |
| 454 | + help="Discover and list available Sendspin servers on the network", |
| 455 | + description="Discover and list available Sendspin servers on the network.", |
| 456 | + ) |
| 457 | + |
| 458 | + # clients subcommand |
| 459 | + clients_parser = subparsers.add_parser( |
| 460 | + "clients", |
| 461 | + help="Client discovery utilities", |
| 462 | + description="Client discovery utilities.", |
| 463 | + ) |
| 464 | + clients_sub = clients_parser.add_subparsers( |
| 465 | + dest="clients_command", |
| 466 | + title="Commands", |
| 467 | + required=True, |
| 468 | + ) |
| 469 | + clients_sub.add_parser( |
| 470 | + "list", |
| 471 | + help="Discover and list available Sendspin clients on the network", |
| 472 | + description="Discover and list available Sendspin clients on the network.", |
| 473 | + ) |
| 474 | + |
421 | 475 | return parser |
422 | 476 |
|
423 | 477 |
|
@@ -613,17 +667,38 @@ def main() -> int: |
613 | 667 | traceback.print_exc() |
614 | 668 | return 1 |
615 | 669 |
|
| 670 | + # Handle utility subcommands |
| 671 | + if args.command == "audio-devices": |
| 672 | + if args.audio_devices_command == "list": |
| 673 | + list_audio_devices() |
| 674 | + return 0 |
| 675 | + |
| 676 | + if args.command == "servers": |
| 677 | + if args.servers_command == "list": |
| 678 | + asyncio.run(list_servers()) |
| 679 | + return 0 |
| 680 | + |
| 681 | + if args.command == "clients": |
| 682 | + if args.clients_command == "list": |
| 683 | + asyncio.run(list_clients()) |
| 684 | + return 0 |
| 685 | + |
616 | 686 | if args.command == PLAYER_APP_SENTINEL: |
617 | | - # Handle player-only actions before starting async runtime. |
| 687 | + # Deprecated flags - route to new subcommands with a warning. |
618 | 688 | if args.list_audio_devices: |
| 689 | + print( |
| 690 | + "Warning: --list-audio-devices is deprecated. Use 'sendspin audio-devices list'.\n" |
| 691 | + ) |
619 | 692 | list_audio_devices() |
620 | 693 | return 0 |
621 | 694 |
|
622 | 695 | if args.list_servers: |
| 696 | + print("Warning: --list-servers is deprecated. Use 'sendspin servers list'.\n") |
623 | 697 | asyncio.run(list_servers()) |
624 | 698 | return 0 |
625 | 699 |
|
626 | 700 | if args.list_clients: |
| 701 | + print("Warning: --list-clients is deprecated. Use 'sendspin clients list'.\n") |
627 | 702 | asyncio.run(list_clients()) |
628 | 703 | return 0 |
629 | 704 |
|
|
0 commit comments