loadContent function
Implementation
FutureOr<String> loadContent(String path, String name, {String? dir}) async {
if (isURL(path)) {
var res = await get(Uri.parse(path));
if (res.statusCode == 200) {
var content = res.body;
return replaceVars(content, name, dir: dir);
} else {
throw CliException(LocaleKeys.error_failed_to_connect.trArgs([path]));
}
} else {
var file = File(path);
if (file.existsSync()) {
var content = file.readAsStringSync();
return replaceVars(content, name, dir: dir);
} else {
throw CliException(LocaleKeys.error_no_valid_file_or_url.trArgs([path]));
}
}
}