getArgumentValue function
Retrieves the value associated with a specific command-line argument key.
This function searches the args list for the given key (e.g., '--clientId').
If the key is found and a value is present immediately after it, that value is returned.
Unlike getArgValue which throws an error, this function returns null
if the key is not found or if no value is associated with it.
args The list of command-line arguments.
key The argument key to search for.
Returns the string value associated with the argument key, or null if
the key is not found or its value is missing.
Implementation
String? getArgumentValue(List<String> args, String key) {
final index = args.indexOf(key);
if (index == -1 || index + 1 >= args.length) {
// throw ArgumentError('Missing value for argument: $key');
return null;
}
return args[index + 1];
}