// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
import 'package:brick_generator/core/string_extension.dart';
import 'package:brick_generator/models/brick_variable.dart';
import 'package:brick_generator/models/variable_type.dart';
import 'package:yaml/yaml.dart';
const _compilableKey = 'compilable';
const _typeKey = 'type';
const _descriptionKey = 'description';
const _defaultKey = 'default';
const _promptKey = 'prompt';
class BrickVariableString extends BrickVariable {
BrickVariableString({
required this.compilable,
required this.syntax,
required super.type,
required super.name,
required super.description,
required super.defaultValue,
required super.prompt,
});
factory BrickVariableString.fromYaml(String key, YamlMap? source) {
if (source == null) {
throw ArgumentError.notNull('source');
}
return BrickVariableString(
compilable: source[_compilableKey] as String? ?? '',
type: VariableType.fromString(source[_typeKey] as String?),
name: key,
description: source[_descriptionKey] as String? ?? '',
defaultValue: source[_defaultKey] as String? ?? '',
prompt: source[_promptKey] as String? ?? '',
syntax: (source[_compilableKey] as String? ?? '').syntaxes,
);
}
String compilable;
Map? syntax;
@override
String toString() => 'BrickVariableString(name: $name, '
'description: $description, compilable: $compilable, '
'defaultValue: $defaultValue, prompt: $prompt,)';
}