discloud_config 1.0.5
discloud_config: ^1.0.5 copied to clipboard
A configuration file handler to use with Discloud host
Overview #
This package provides a comprehensive set of tools for managing discloud.config
files. It allows you to read, write, and validate your Discloud configurations with ease. The package is designed to be used in Dart applications that interact with the Discloud hosting service.
Useful links #
Installation #
Add it to your pubspec.yaml
as a dependencies by running the following command.
dart pub add discloud_config
Usage #
Import #
import 'package:discloud_config/discloud_config.dart';
Make an instance #
/// the [lines] argument receives a list of lines from the configuration file contents
DiscloudConfig(File, [List<String>?]);
- It can also be asynchronous
// import 'dart:io';
await DiscloudConfig.fromFileSystemEntity(FileSystemEntity);
await DiscloudConfig.fromPath(String);
await DiscloudConfig.fromUri(Uri);
Watch configuration file #
DiscloudConfigData
is read-only, seeUpdating DiscloudConfigData
- It works until the file is
moved
ordeleted
// Stream<DiscloudConfigData>
await for (final DiscloudConfigData data in config.watch()) {
// ...
}
Create a new DiscloudConfigData from JSON #
DiscloudConfigData.fromJson(Map<String, dynamic>);
Updating DiscloudConfigData #
// Convert to raw data
final Map<String, dynamic> oldRawData = oldData.toJson();
// Update raw data
oldRawData["TYPE"] = "bot";
// Convert to data
final newData = DiscloudConfigData.fromJson(oldRawData);
List all configuration files recursively #
// Stream<File>
await for (final File file in listDiscloudConfigFiles(Directory)) {
// ...
}
Recursively list configuration structures by ID #
// Stream<DiscloudConfig>
await for (final DiscloudConfig config in listDiscloudConfigByAppId(Directory, String)) {
// ...
}
Contributing #
We welcome a diverse set of contributions, including, but not limited to:
- Filing bugs and feature requests
- Send a pull request
- Or, create something awesome using this API and share with us and others!
For the stability of the API and existing users, consider opening an issue first before implementing a large new feature or breaking an API. For smaller changes (like documentation, minor bug fixes), just send a pull request.
Testing #
All pull requests are validated against CI, and must pass.
Ensure build runs
dart run build_runner build
Ensure code passes all our analyzer checks:
dart analyze
Ensure all code is formatted with the latest dev-channel SDK.
dart format .
Run all of our unit tests:
dart test
License #
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.