What does DCli do?
DCli has a singular focus:
make it easy to build command line apps using the Dart programming language.
DCli has the following aims:
make building CLI apps as easy as walking.
fully utilise the expressiveness of Dart.
works seamlessly with the core Dart libraries.
provide a cross platform API for Windows, OSx and Linux.
call any CLI app.
make debugging CLI apps easy.
generate error messages that make it easy to resolve problems.
provide quality documentation and examples.
DCli's API covers a number of areas:
User input
Asking the user to input data into a CLI application should be simple. DCli provides a number of functions to facilitate user input.
ask
confirm
menu
DCli provides an extensive API designed specifically for building command-line apps.
Displaying information
Out-of-the-box Dart provides the basic 'print' statement which DCli extends to provide common features.
print
printerr - prints to stderr.
colour coding
cursor management
clear screen/clear line
Manage files and directories
A fundamental task of most CLI applications is the management of files and directories. DCli provides a large set of tools for file management such as:
find
which
copy
copyTree
move
moveTree
delete
deleteDir
touch
exists
isWritable/isReadable/isExecutable
isFile
isLink
isDirectory
lastModified
Dart has a large ecosystem of packages that you can use to extend the DCli such as the excellent paths package that lets you easily manipulate file paths.
Read/Write files
You are often going to need to read/write and modify text and binary files.
read
write
truncate
append
replace
tail
cat
You still have full access to the full set of Dart APIs
Call command line apps
A core feature of DCli is the ability to call other CLI apps and process their output.
run
start
toList
forEach
firstLine
lastLine
| (pipe)
stream
Run mysql with all output being displayed to the console.
Run a mysql command and store the results in a list (users).
Explore you environment
DCli makes it easy to explore your environment with direct manipulation of environment variables.
PATH management tools:
And the ability to explore the Dart environment.
You can explore the complete API here.
Last updated