|
33 | 33 | parser.add_argument('-r', '--reconnect-interval', type=int, default=2, help='Reconnect interval (seconds, default: 2)')
|
34 | 34 | parser.add_argument('-I', '--initial-messages', type=str, help='Send the messages from this file on connect')
|
35 | 35 | parser.add_argument('-P', '--plugin', type=str, help='Plugin file to load')
|
36 |
| -parser.add_argument( '--plugin-provided-url', action='store_true', default=False, help='Plugin file to load') |
| 36 | +parser.add_argument( '--plugin-provided-url', action='store_true', default=False, help='Indicates if plugin provided dynamic url for websockets') |
37 | 37 | parser.add_argument('-v', '--verbose', type=int, default=3, help='Verbosity level, 1-4 default: 3 (errors, warnings, info), 4 adds debug')
|
38 | 38 |
|
39 | 39 | def cli():
|
40 | 40 | args = parser.parse_args()
|
41 | 41 | url = args.url or args.url_positional
|
42 |
| - if url and not args.plugin_provided_url: |
| 42 | + if url and args.plugin_provided_url is False: |
43 | 43 | # Check and modify the URL protocol if necessary
|
44 | 44 | if url.startswith('http://'):
|
45 | 45 | return url.replace('http://', 'ws://', 1)
|
46 | 46 | elif url.startswith('https://'):
|
47 | 47 | return url.replace('https://', 'wss://', 1)
|
48 | 48 | elif not url.startswith(('ws://', 'wss://')):
|
49 | 49 | parser.error('Invalid protocol. Supported protocols are http://, https://, ws://, and wss://.')
|
50 |
| - elif args.plugin_provided_url and not args.plugin: |
51 |
| - parser.error('Please provide a WebSocket URL using either -u as a positional argument or use --plugin-provided-url if the WebSocket URL provided in a plugin') |
| 50 | + elif args.plugin_provided_url is False and args.plugin is not None: |
| 51 | + parser.error('Please provide a WebSocket URL using -u or use --plugin-provided-url if the WebSocket URL provided in a plugin') |
| 52 | + else: |
| 53 | + parser.error('Please provide either a WebSocket URL using -u or use --plugin-provided-url with --plugin if the WebSocket URL provided in a plugin') |
52 | 54 |
|
53 | 55 | app = WSRepl(
|
54 | 56 | url=url,
|
|
0 commit comments