concept command - line argument in category dart

appears as: commd-line arguments, commd-line arguments
Dart in Action

This is an excerpt from Manning's book Dart in Action.

The Dart File Browser example project scenario for this chapter has a client-and-server solution that provides a browser-based text editor for editing Dart files, which we’ll tackle in three steps starting with the server side. The server-side Dart VM is hosted in a command-line executable, available for Windows, Mac, and Linux. We’ll begin by looking at how you can write a simple Dart script that interacts with the filesystem, passing command-line arguments to output a directory listing.

13.1.1. Accessing command-line arguments

Dart provides the Options type to access command-line arguments. Creating an instance of Options with the new keyword gives you a fully populated object containing the path to the current Dart executable binary, the script file containing the main() function, and a list containing the arguments passed on the command line. Listing 13.1, which prints the following output to the console when run with the command, shows a simple Dart script to output the command-line arguments and information about the executing script:

Listing 15.6. DirAnalysis.dart: reading the command-line arguments