Skip to content

Commit

Permalink
lint fixes & proper doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
canewsin committed Mar 5, 2023
1 parent 32b87ce commit b4c57cf
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 127 deletions.
87 changes: 46 additions & 41 deletions lib/extensions/callbacks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,44 @@ import '../constants.dart';
import '../interface.dart';

extension UiServerExt on ZeroNet {
void announcerInfo({MessageCallback? callback}) => ZeroNet.instance.cmd(
void announcerInfo({
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.announcerInfo,
callback: callback ?? onMessage,
);

void certAdd(
String domain,
String auth_type,
String auth_user_name,
String authType,
String authUserName,
String cert, {
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.certAdd,
params: {
'domain': domain,
'auth_type': auth_type,
'auth_user_name': auth_user_name,
'auth_type': authType,
'auth_user_name': authUserName,
'cert': cert,
},
callback: callback ?? onMessage,
);

void certSelect({
List<String>? accepted_domains,
String? accept_any,
String? accepted_pattern,
List<String>? acceptedDomains,
String? acceptAny,
String? acceptedPattern,
MessageCallback? callback,
}) {
var params = {};
if (accepted_domains != null) {
params['accepted_domains'] = accepted_domains;
if (acceptedDomains != null) {
params['accepted_domains'] = acceptedDomains;
}
if (accept_any != null) params['accept_any'] = accept_any;
if (accepted_pattern != null) params['accepted_pattern'] = accepted_pattern;
if (acceptAny != null) params['accept_any'] = acceptAny;
if (acceptedPattern != null) params['accepted_pattern'] = acceptedPattern;

ZeroNet.instance.cmd(
ZeroNetCmd.certSelect,
Expand Down Expand Up @@ -69,31 +72,31 @@ extension UiServerExt on ZeroNet {
);

void dirList(
String inner_path, {
String innerPath, {
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.dirList,
params: {
'inner_path': inner_path,
'inner_path': innerPath,
},
callback: callback ?? onMessage,
);

void fileDelete(
String inner_path, {
String innerPath, {
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.fileDelete,
params: {
'inner_path': inner_path,
'inner_path': innerPath,
},
callback: callback ?? onMessage,
);

void fileGet(
String inner_path, {
String innerPath, {
bool required = true,
String format = 'text',
int timeout = 300,
Expand All @@ -102,7 +105,7 @@ extension UiServerExt on ZeroNet {
ZeroNet.instance.cmd(
ZeroNetCmd.fileGet,
params: {
'inner_path': inner_path,
'inner_path': innerPath,
'required': required,
'format': format,
'timeout': timeout,
Expand All @@ -112,67 +115,67 @@ extension UiServerExt on ZeroNet {
}

void fileList(
String inner_path, {
String innerPath, {
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.fileList,
params: {
'inner_path': inner_path,
'inner_path': innerPath,
},
callback: callback ?? onMessage,
);

void fileNeed(
String inner_path, {
String innerPath, {
int timeout = 300,
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.fileNeed,
params: {
'inner_path': inner_path,
'inner_path': innerPath,
'timeout': timeout,
},
callback: callback ?? onMessage,
);

void fileQuery(
String dir_inner_path, {
String dirInnerpath, {
String query = '',
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.fileQuery,
params: {
'dir_inner_path': dir_inner_path,
'dir_inner_path': dirInnerpath,
'query': query,
},
callback: callback ?? onMessage,
);

void fileRules(
String inner_path, {
String innerPath, {
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.fileRules,
params: {
'inner_path': inner_path,
'inner_path': innerPath,
},
callback: callback ?? onMessage,
);

void fileWrite(
String inner_path,
String content_base64, {
String innerPath,
String contentBase64, {
MessageCallback? callback,
}) =>
ZeroNet.instance.cmd(
ZeroNetCmd.fileWrite,
params: {
'inner_path': inner_path,
'content_base64': content_base64,
'inner_path': innerPath,
'content_base64': contentBase64,
},
callback: callback ?? onMessage,
);
Expand All @@ -195,13 +198,13 @@ extension UiServerExt on ZeroNet {

void sitePublish({
String? privatekey,
String? inner_path,
String? innerPath,
bool sign = true,
MessageCallback? callback,
}) {
var params = {};
if (privatekey != null) params['privatekey'] = privatekey;
if (inner_path != null) params['inner_path'] = inner_path;
if (innerPath != null) params['inner_path'] = innerPath;
params['sign'] = sign;
ZeroNet.instance.cmd(
ZeroNetCmd.sitePublish,
Expand All @@ -217,14 +220,14 @@ extension UiServerExt on ZeroNet {

void siteSign({
String privatekey = 'stored',
String? inner_path,
bool remove_missing_optional = false,
String? innerPath,
bool removeMissingOptional = false,
MessageCallback? callback,
}) {
var params = {};
if (inner_path != null) params['inner_path'] = inner_path;
if (innerPath != null) params['inner_path'] = innerPath;
params['privatekey'] = privatekey;
params['remove_missing_optional'] = remove_missing_optional;
params['remove_missing_optional'] = removeMissingOptional;
ZeroNet.instance.cmd(
ZeroNetCmd.siteSign,
params: params,
Expand Down Expand Up @@ -310,11 +313,13 @@ extension AdminExt on ZeroNet {

void serverUpdate() => ZeroNet.instance.cmd(ZeroNetCmd.serverUpdate);

void siteClone(String address, String root_inner_path) =>
ZeroNet.instance.cmd(ZeroNetCmd.siteClone, params: {
'address': address,
'root_inner_path': root_inner_path,
});
void siteClone(String address, String rootInnerPath) => ZeroNet.instance.cmd(
ZeroNetCmd.siteClone,
params: {
'address': address,
'root_inner_path': rootInnerPath,
},
);

void siteList({MessageCallback? callback}) => ZeroNet.instance.cmd(
ZeroNetCmd.siteList,
Expand Down
18 changes: 9 additions & 9 deletions lib/extensions/core/admin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ part of '../futures.dart';
/// Site should hold `ADMIN` permission to access these cmds.
/// Otherwise return value will an Error
extension AdminExt on ZeroNet {
///Return: Command's return value.
/// Return: Command's return value.
Future<MessageOrPromptOrError> asFuture({
required String site,
required String cmd,
Expand Down Expand Up @@ -31,7 +31,7 @@ extension AdminExt on ZeroNet {
return result.toMsgOrErr;
}

///Return: ok
/// Return: ok
Future<MessageOrError> permissionRemoveFuture(String permission) async {
final result = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.permissionRemove,
Expand All @@ -42,7 +42,7 @@ extension AdminExt on ZeroNet {
return result.toMsgOrErr;
}

///Return: ok
/// Return: ok
Future<MessageOrError> permissionDetailsFuture(String permission) async {
final res = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.permissionDetails,
Expand Down Expand Up @@ -72,7 +72,7 @@ extension AdminExt on ZeroNet {
return resultStr.toMsgOrErr;
}

///Return: Message
/// Return: Message
Future<MessageOrError> certSetFuture(String domain) async {
final res = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.certSet,
Expand All @@ -83,7 +83,7 @@ extension AdminExt on ZeroNet {
return res.toMsgOrErr;
}

///Return: Message
/// Return: Message
Future<MessageOrError> channelJoinAllSiteFuture(String channel) async {
final res = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.channelJoinAllsite,
Expand All @@ -94,7 +94,7 @@ extension AdminExt on ZeroNet {
return res.toMsgOrErr;
}

///Return: ok
/// Return: ok
Future<MessageOrError> configSetFuture(String key, String value) async {
var resultStr = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.configSet,
Expand All @@ -114,7 +114,7 @@ extension AdminExt on ZeroNet {
return resultStr.toMsgOrErr;
}

///Return: None
/// Return: None
Future<PromptOrError> serverShutdownFuture({bool restart = false}) async {
final resultStr = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.serverShutdown,
Expand All @@ -125,15 +125,15 @@ extension AdminExt on ZeroNet {
return resultStr.toPromptOrErr;
}

///Return: None
/// Return: None
Future<PromptOrError> serverUpdateFuture() async {
final resultStr = await ZeroNet.instance.cmdFuture(
ZeroNetCmd.serverUpdate,
);
return resultStr.toPromptOrErr;
}

///Return: None, automatically redirects to new site on completion
/// Return: None, automatically redirects to new site on completion
Future<MessageOrPromptOrError> siteCloneFuture(
String address,
String rootInnerPath,
Expand Down
Loading

0 comments on commit b4c57cf

Please sign in to comment.