darted_cli 0.1.19 copy "darted_cli: ^0.1.19" to clipboard
darted_cli: ^0.1.19 copied to clipboard

darted_cli is a customizable Dart CLI framework for building command-line tools with hierarchical command structures, argument parsing, and flag management.

example/lib/main.dart

import 'package:darted_cli/yaml_module.dart';

class PackageLogic {
  static doSomething() {}
  // --> Starting 0.0.18, Using Yaml Validation!
  manipulateYaml() async {
    //1. Supply a validation Schema
    final yamlSchema = YamlValidationSchema(
      fields: {
        'some_key': FieldRule(type: 'string', required: true),
        'another_key': FieldRule(
          type: 'map',
          required: false,
          nestedFields: {
            'nested_1': FieldRule(type: 'string', required: true),
            'nested_2': FieldRule(type: 'string', required: false),
          },
        ),
        'some_options': FieldRule(
          type: 'map',
          required: false,
          nestedFields: {
            'enable_this': FieldRule(type: 'bool', required: false),
            'has_these': FieldRule(type: 'list', required: false),
          },
        ),
      },
    );
    //2. Load the yaml file.
    final yamlFilePath = 'path/to/yaml';
    final YamlMap yamlContent = await YamlModule.load(yamlFilePath);
    //2. Validate the Yaml content with the schema.
    try {
      await YamlModule.validate(yamlContent, yamlSchema);
      print('Validation successful! The configuration file is correct.');
    } catch (e) {
      print('Validation failed: $e');
    }
    // --> Starting 0.0.19, Extract your Yaml data!
    Map<String, dynamic> yamldata = YamlModule.extractData(yamlContent);
    print('Extracted data: $yamldata');
  }
}
2
likes
160
points
877
downloads

Publisher

verified publishermicazi.dev

Weekly Downloads

darted_cli is a customizable Dart CLI framework for building command-line tools with hierarchical command structures, argument parsing, and flag management.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

enough_ascii_art, yaml

More

Packages that depend on darted_cli