You can use Dart for any kind of command-line app from scripts to servers.
- Show me the code
- Best place to start
- Basic command-line apps
- Read all about it
- Prerequisites (dart:async library)
- The Basics
- Shell scripting
- Reference docs
Show me the code
If you prefer to plow through code, start with the following examples.
These samples progress from simple to complex
and illustrate a variety of APIs specific to command-line apps and servers.
- Using files, directories, and symlinks
- Reading and writing files
- Listing contents of directories
- Using streams
- Making HTTP requests
- Getting the response
- Handling errors
- Serving index.html
- Adding custom headers
- Implementing an HTTP server
- …and more…
- Parsing command-line arguments
- Reading a file
- Converting data
- Using stdin, stdout, and stderr
- Listing a directory recursively
- Testing and getting information about paths
- Using the HttpServer class
- Handling GET, POST, and OPTIONS requests
- Using CORS headers
- Using WebSockets
- Getting responses
- Routing requests
- Handling errors
Read all about it
Follow these links in order to gain a full understanding
of how to write different kinds of command-line apps in Dart using
various Dart libraries and packages.
Prerequisites (dart:async library)
Kevin Moore created a five-part video series on shell scripting with Dart.
Read more about
shell scripting with Dart.
Virtual directory, virtual host, and static file serving. (Dart team)
URL routing for the server (and the client). (Dart team)
Handle command-line arguments. (Dart team)
Connect to HTTP resources. (Dart team)
Find more packages useful for server-side and command-line apps
Includes support for UDP, TCP, HTTP client and server,
files, directories, web sockets, processes, server sockets, and more.
- args package—
Help with handling command-line arguments.
Asynchronous programming with Futures, Streams.
Converters for data types such as JSON and UTF-8.