This chapter will teach you how to build command-line applications. The programs used all the needs to build application including the standard output, error, and input streams, command-line arguments, files and directories, and more. To run a command-line app in the Dart VM, use dart run. Let’s run a small program.
1.Create a file called hello_world.dart that contains this code:
void main() {
print('Hello, World!');
}
2.In the directory that contains the file you just created, run the program:
$ dart run hello_world.dart
Hello, World!
You can use dart –help coommand to see commonly used commands and options.Use dart –verbose to see all options.
You might notice that dcat depends on a package named args. To get the args package, use the pub package manager.
A real app has tests, license files, dependency files, examples, and so on. For the first app though, we can easily create only what is necessary with the dart create command.
1.Inside a directory, create the dcat app with the dart tool.
$ dart create dcat
2.Change to the created directory.
$ cd dcat
3.Inside the dcat directory, use dart pub add to add the args package as a dependency. This adds args to the list of your dependencies found in the pubspec.yaml file.
$ dart pub add args
4.Open the bin/dcat.dart file and copy the preceding code into it.