dfn library

dfn Use Dart as your scripting language, and register scripts from anywhere.

# activate dfn
dart pub global activate dfn

# see usage
dfn --help

Classes

DfnConfig
Dart representation of the .dfn file.

Enums

RegisterSource
The type of register script.

Extensions

Fit on String
Helper to fit command usage string.

Constants

version → const String
Current version of dfn.

Properties

bold String? Function(String? value, {bool forScript = false})
Helper for decorating strings as bold.
final
dfnConfigAddUsage String
Usage information of dfn config add command:
final
dfnConfigRemoveUsage String
Usage for dfn config remove or dfn config rm command.
final
dfnConfigUsage String
Usage for dfn config command:
final
dfnUsage String
dfn -h or dfn --help output:
final
home String?
Path to the user's "home" directory.
final
italic String? Function(String? value, {bool forScript = false})
Helper for decorating strings as italic.
final

Functions

checkForUpdate(DfnConfig config, Logger logger) Future<DfnConfig>
Checks if a new update is available notifies via logger message. Return DfnConfig to be use in rest of application.
checkVerbose(List<String> arguments, Logger logger) → void
Check if --verbose is the first argument and then sets the logger to verbose mode.
getConfig(Logger logger) DfnConfig
Retrieve the dfn configuration. Will create the configuration if it does not exist.
handleAdd(List<String> arguments, Logger logger, DfnConfig configuration) Future<int>
Handler for dfn config add command.
handleConfig(List<String> arguments, Logger logger, DfnConfig config) Future<int>
Handler for dfn config command.
handleHelp(List<String> arguments, Logger logger, DfnConfig _) int
Handler for the dfn -help or dfn -h option.
handleList(List<String> arguments, Logger logger, DfnConfig config) Future<int>
Handler for dfn ls, dfn list command.
handleRemove(List<String> arguments, Logger logger, DfnConfig config) Future<int>
Handler for dfn config remove or dfn config rm command.
handleTarget({required String target, required DfnConfig config, required List<String> args, required Logger logger}) Future<int>
Handler for dfn <target|script>. Execute a script/command file from in this order:
lsScriptFiles({required DfnConfig config, required void onInvalidPath(String), required Logger logger}) Stream<({File file, RegisterSource type})>
Emits all registered scripts in config.
run(List<String> arguments, Logger logger) Future<int>
Entry point for dfn command.
writeConfig(DfnConfig config, Logger logger) DfnConfig
Write to the dfn configuration file. Will create the configuration if it does not exist.

Typedefs

Handler = FutureOr<int> Function(List<String> arguments, Logger logger, DfnConfig config)
Function for handling commands and options.