Skip to content

Commit 59708be

Browse files
committed
Added checks to ensure correct variable combos are provided
1 parent 4aee6c5 commit 59708be

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

wsrepl/cli.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,24 @@
3333
parser.add_argument('-r', '--reconnect-interval', type=int, default=2, help='Reconnect interval (seconds, default: 2)')
3434
parser.add_argument('-I', '--initial-messages', type=str, help='Send the messages from this file on connect')
3535
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')
3737
parser.add_argument('-v', '--verbose', type=int, default=3, help='Verbosity level, 1-4 default: 3 (errors, warnings, info), 4 adds debug')
3838

3939
def cli():
4040
args = parser.parse_args()
4141
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:
4343
# Check and modify the URL protocol if necessary
4444
if url.startswith('http://'):
4545
return url.replace('http://', 'ws://', 1)
4646
elif url.startswith('https://'):
4747
return url.replace('https://', 'wss://', 1)
4848
elif not url.startswith(('ws://', 'wss://')):
4949
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')
5254

5355
app = WSRepl(
5456
url=url,

0 commit comments

Comments
 (0)