ft library

Support for doing something awesome.

More dartdocs go here.

Enums

ArchiveType
FileWriteLevel
FormatField
PathAction
enum available path action
StatTimeType
file stat time type
TimeUnit
Recognized time units for parsing "time ago" strings.

Mixins

BasicAction

Extension Types

Es
extension type (FileSystemEntity, FileStat, String)

Extensions

CommandExtension on Command
extension Command, override invocation
TimeUnitExtension on TimeUnit
Utility extension for TimeUnit.

Constants

ampersandDelimiter → const String
Delimiter: an ampersand (&).
archiveTypeMapper → const Map<String, String>
basicArchiveExtAllows → const List<String>
commaDelimiter → const String
Delimiter: a comma (,).
dotDelimiter → const String
Delimiter: a single dot (.).
equalsignDelimiter → const String
Delimiter: an equals sign (=).
kIsDebug → const bool
months_ → const List<String>
semicolonDelimiter → const String
Delimiter: a semicolon (;).
sizeGB → const int
sizeKB → const int
sizeMB → const int
sizePB → const int
sizeTB → const int
spaceDelimiter → const String
Delimiter: a single space ( ).
timeUnits → const List<String>
Supported time unit strings for parsing and validation.

Properties

environ Map<String, String>
A map of environment variables for the current process.
final
fieldNames List<String>
final
ftOs String
The operating system name string for 'ft'.
final
ftTmplName String
The default template filename for 'ft'.
final
ftTmplText String
The default template text for 'ft'.
final
ftVer String
The version string for 'ft'.
final
homePath String
determine the user's home directory.
no setter
homePathDocuments String
define the path to the user's Documents folder.
final
homePathDownloads String
define the path to the user's Downloads folder.
final
homePattern String
define the platform-specific home directory pattern
final
isDesktop bool
True if the current operating system is a desktop OS (Windows, Linux, or macOS).
no setter
isUnixLike bool
True if the current operating system is Linux or macOS.
no setter
isWindows bool
True if the current operating system is Windows.
final
lineEnd String
The platform-specific line terminator string.
final
pathjoin String Function(String part1, [String? part2, String? part3, String? part4, String? part5, String? part6, String? part7, String? part8, String? part9, String? part10, String? part11, String? part12, String? part13, String? part14, String? part15, String? part16])
Joins the given path parts into a single path using the current platform's separator. Example:
getter/setter pair
pathSep String
The platform-specific path separator character.
final
regexSizeInput RegExp
match a human-readable file size
getter/setter pair
timeAgoRegExp RegExp
Regex to parse "N unit ago" strings (e.g., "5 minutes ago").
final
timeTypeDefault String
final
timeTypes List<String>
final
varInputRegexp RegExp
match input variable, e.g. ${VAR}, $VAR, %VAR%.
final
varTimeAgoRegexp RegExp
match dynmaic variable, time ago.
final

Functions

archiveName(String path, [ArchiveType type = ArchiveType.tgz, List<String> extAllows = basicArchiveExtAllows]) → (String, ArchiveType)
create archive name from path and type
cmdRunner(List<String> args) FtRunner
filetool run
compressTilde(String path) String
compress tilde with path
configFromArgParse(ArgParser argParse, List<String> arguments, {Map<String, String>? environment, Uri? workingDirectory}) → Config
doTextMimeAdd(String extension, String mimeType) → void
Adds a custom text MIME type mapping for a given file extension.
doTextMimeInit() → void
Initializes the custom text MIME type resolver with predefined mappings.
expandDotPath(String path) String
Expands a path that starts with '.' or '..' to an absolute path.
expandTilde(String path) String
expand tilde with path
expandVar(String path, {Map<String, String> map = const {}}) String
expand variables in a string path using provided map collections and and built-in dynamic variable
fieldsFromOptions(List<String> options) List<FormatField>
fileMirror(File srcFile, File dstFile) File
Efficiently mirrors srcFile content to dstFile, copying only if necessary.
fileOverWrite(File file, {bool? isFileExist, FileWriteLevel level = FileWriteLevel.medium, bool autoDelete = true}) bool
Overwrite the content of a file based on the specified level pattern.
formatTimeAgo(DateTime dateTime) String
This function calculates the time difference between the provided dateTime and the current moment (DateTime.now()) and returns a string in an approximate, user-friendly format.
getCrc64(List<int> array, [int crc = 0]) int
Get the CRC-64 checksum of the given array.
getCrc64_(List<int> array, [int crc = 0]) int
Get the CRC-64 checksum of the given array.
getDefine(Config config, ArgResults? gRes) Map<String, String>
get define input, order: env-> define -> yaml
getExecBlock(Config config, Map<String, String> env, [List<String> blocks = const []]) Map<String, List<String>>
get commands input from yaml
getFlag(String name, Config config, {bool defaultTo = false, ArgResults? gRes, ArgResults? aRes}) bool
notDefined get bool input, order: define -> env -> yaml -> globalResults -> argResults
getInt(String name, Config config, {int defaultTo = 0, int? max, ArgResults? gRes, ArgResults? aRes}) int
get bool input, order: define -> env -> yaml -> globalResults -> argResults
getOpiton(String name, Config config, {bool isNotEmpty = true, String defaultTo = '', List<String> datalist = const [], ArgResults? gRes, ArgResults? aRes}) String
get option input, order: define -> env -> yaml -> globalResults -> argResults
getOpitons(String name, Config config, {bool isNotEmpty = false, List<String> defaults = const [], List<String> datalist = const [], ArgResults? gRes, ArgResults? aRes}) List<String>
get options input, order: define -> env -> yaml -> globalResults -> argResults
getShellBlock(Config config, Map<String, String> env, String workdir, [List<String> blocks = const []]) Map<String, List<String>>
get scripts input from yaml
getShellScripts(Config config, Map<String, String> env, String workdir) List<String>
get scripts input from yaml
getSizes(Config config, ArgResults? gRes) List<int>
get size input, order: define -> env -> yaml -> argResults
getSource(Config config, ArgResults? gRes, {ArgResults? aRes, Map<String, String>? env}) String
get source input, order: define -> env -> yaml -> argResults -> rest first
getTarget(String name, Config config, {ArgResults? aRes, Map<String, String>? env, String? source}) String
get target input, order: define -> env -> yaml -> argResults -> rest last
getTimes(Config config, ArgResults? gRes) List<DateTime>
get times input, order: define -> env -> yaml -> argResults
hrSizes(List<int> sizes) List<String>
Convert file sizes to human-readable format
humanReadableSize(int sizeInBytes) String
Converts a file size in bytes to a human-readable format (e.g., KB, MB, GB).
humanReadableTime(DateTime mtime, [List<String> months = months_]) String
Format a given DateTime object into a human-readable time string.
isAllowArchiveType(String filename, [List<String> extAllows = basicArchiveExtAllows]) bool
isCrc64Supported() bool
isCrc64Supported_() bool
isDirEmpty(Directory directory, {bool? isDirExist}) bool
Checks if a directory is empty synchronously.
isDirWritable(Directory directory, {bool? isDirExist}) bool
Checks if a directory is writable by the current process.
isInSizes(int value, {int? min, int? max}) bool
Check a file size value within a specified range min, max.
isInTimes(DateTime value, {DateTime? min, DateTime? max}) bool
Check a file time value within a specified range min, max.
isMatchGlob(String pattern, String path) bool
Checks if a path matches a glob pattern.
isOsMatched(String name) bool
Checks if the given name matches the current platform's operating system.
isSubCmd(String cmd, List<String> subCmdNames) bool
check cmd has valid subCmdNames
isTextMimeType(String path, {List<int>? headerBytes}) bool
Checks if a file is considered a text file based on its MIME type.
joinDelimiter(List<String> names, [String delimiter = dotDelimiter]) String
Joins a list of names into a single string using the specified delimiter.
parseAssigns(List<String> assigns) Map<String, String>
Parses a list of key=value assigns strings into a Map. Skips invalid entries.
parseCliArgs(String command, {bool isRawString = true}) List<String>
Parse a CLI command string into a list of its full arguments, including the command name itself.
parseCliAssigns(String cli) Map<String, String>
Parses cli command arguments into a Map of key-value assignments
parseHumanReadableSize(String humanSize) int?
Parse a human-readable file size (e.g., KB, MB, GB) to bytes.
parseHumanReadableTime(String humanTime, [List<String> months = months_]) DateTime?
Parse a human-readable time string
pathderoot(String path) String
DeRoot an absolute path
pathextract(String text) List<String>
Extract all possible local file and directory from the provided text
pathtail(String path, int n) String
Get the last n segment of a path.
shiftDown64(int value) int
splitHumanReadableSize(String humanSize) → (double, String)?
Split a human-readable file size to (value, unit)
tails<T>(List<T> lists, int n) List<T>
Get the last n elements from lists.
traceGlobalParam(Logger logger, FtRunner ftRun, String source) → void
unArchive(File file, Directory dir, List<FormatField> fields, {bool useRelPath = true, Logger? logger, bool? isDirWritable}) → void
unarchive filename to pathname,
unArchiveValidator(File file, Directory dir, [bool? isWritable, List<String> extAllows = basicArchiveExtAllows]) String
undefined(String input, Map<String, String> literal) String
return input undefined variable in literal
valueAgoInput(String agoType, String agoInput) String
value of dynamic variable time ago sucess return YYYYMMDD|YYYYMMDDHHMMSS