print update
This commit is contained in:
parent
a9c3e03d1c
commit
e8cde08885
4 changed files with 37 additions and 25 deletions
|
|
@ -87,8 +87,6 @@ abstract class Command {
|
|||
|
||||
static RegExp regEx = RegExp(r'(<!)([_a-zA-Z0-9.-]+)(>)');
|
||||
|
||||
static final Map<String, dynamic> _cache = <String, dynamic>{};
|
||||
|
||||
static Future setReturnValue(String tag, dynamic value) async {
|
||||
var match = regEx.firstMatch(tag);
|
||||
tag = match!.group(2)!;
|
||||
|
|
@ -127,11 +125,8 @@ abstract class Command {
|
|||
var list = regEx.allMatches(raw);
|
||||
for (var match in list) {
|
||||
var param = match.group(2);
|
||||
if (!_cache.containsKey(param)) {
|
||||
_cache[param!] = _getTagValue(param);
|
||||
}
|
||||
var target = '<!${param!}>';
|
||||
raw = raw.replaceAll(target, _cache[param].toString());
|
||||
raw = raw.replaceAll(target, _getTagValue(param).toString());
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:dart_framework/core/app_data_manager.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/cli/cli.dart';
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
|
|
@ -30,13 +31,24 @@ abstract class PiplineCondition extends PipelineExecutor {
|
|||
'string': (value) => value == 'null' ? null : value,
|
||||
'bool': (value) =>
|
||||
value == 'null' ? null : (value.toLowerCase() == 'true') as bool?,
|
||||
'version': (value) => value == 'null' ? null : value
|
||||
'version': (value) => value == 'null'
|
||||
? null
|
||||
: AppDataManager.to.versionToNumber(value) as double?
|
||||
};
|
||||
return PipelineValidateResult();
|
||||
}
|
||||
|
||||
Future<ConditionCheckResult> checkCondition(
|
||||
String syntax, String condition) async {
|
||||
Future printCondition(
|
||||
String syntax, String postfix, ConditionCheckResult result) async {
|
||||
var quotesPre = Platform.isWindows ? '^"' : '';
|
||||
var quotesLast = Platform.isWindows ? '"' : '';
|
||||
var printStr =
|
||||
'$quotesPre[$syntax] (${result.conditionValue}) : ${result.result}$postfix$quotesLast';
|
||||
await CLI.println(printStr, color: Color.magentaStrong);
|
||||
return simpleFuture;
|
||||
}
|
||||
|
||||
ConditionCheckResult checkCondition(String condition) {
|
||||
var result = ConditionCheckResult();
|
||||
for (var item in conditions.entries) {
|
||||
if (condition.contains(item.key)) {
|
||||
|
|
@ -46,21 +58,10 @@ abstract class PiplineCondition extends PipelineExecutor {
|
|||
result.conditionValue = '$value0${item.key}$value1';
|
||||
result.result = item.value(value0, value1, types[data.type]!);
|
||||
|
||||
var display = true;
|
||||
if (syntax == 'WHILE' && !result.result) {
|
||||
display = true;
|
||||
}
|
||||
if (display) {
|
||||
var quotesPre = Platform.isWindows ? '^"' : '';
|
||||
var quotesLast = Platform.isWindows ? '"' : '';
|
||||
var printStr =
|
||||
'$quotesPre[$syntax] (${result.conditionValue}) : ${result.result}$quotesLast';
|
||||
await CLI.println(printStr, color: Color.magentaStrong);
|
||||
}
|
||||
return dataFutrue(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return dataFutrue(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ class PipelineIf extends PiplineCondition {
|
|||
|
||||
@override
|
||||
Future execute() async {
|
||||
var result = await checkCondition('IF', data.condition!);
|
||||
var result = checkCondition(data.condition!);
|
||||
await printCondition('IF', getPostfix(result.result), result);
|
||||
if (result.result) {
|
||||
await _pipelineTrue?.execute();
|
||||
} else {
|
||||
|
|
@ -44,4 +45,16 @@ class PipelineIf extends PiplineCondition {
|
|||
}
|
||||
return simpleFuture;
|
||||
}
|
||||
|
||||
String getPostfix(bool condition) {
|
||||
if (condition) {
|
||||
return _pipelineTrue == null
|
||||
? ' ====> on-true not exist. Passed'
|
||||
: ' ====> Execute: on-true ';
|
||||
} else {
|
||||
return _pipelineFalse == null
|
||||
? ' ====> on-false not exist. Passed'
|
||||
: ' ====> Execute: on-false ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/cli/cli.dart';
|
||||
import 'package:oto_cli/oto/data/pipeline_data.dart';
|
||||
import 'package:oto_cli/oto/pipeline/pipeline.dart';
|
||||
import 'package:oto_cli/oto/pipeline/pipeline_condition.dart';
|
||||
|
|
@ -28,9 +29,11 @@ class PipelineWhile extends PiplineCondition {
|
|||
|
||||
@override
|
||||
Future execute() async {
|
||||
var result = await checkCondition('WHILE', data.condition!);
|
||||
if (result.result) {
|
||||
var result = checkCondition(data.condition!);
|
||||
while (result.result) {
|
||||
await printCondition('While', ' ====> Execute: on-do', result);
|
||||
await _pipelineOnDo?.execute();
|
||||
result = checkCondition(data.condition!);
|
||||
}
|
||||
return simpleFuture;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue