본문 바로가기
개발/dart

12. Write Command-Line Apps

by 허허 그림 2014. 3. 17.
728x90

드디어 Dart 튜토리얼 12 챕터까지 한글 번역 완료했다.

참고로: 오역과 오타가 많을 수 있어 원문과 함께 등록했습니다.
번역은 문단 단위로 했습니다. 그래서 영어 한 문단 밑에 한글로 번역한 문단이 있습니다.


* 전체 링크

- 1.get started

- 2. Connect Dart & HTML

- 3. Add Elements to the DOM

- 4, Remove DOM Elements

- 5. Install Shared Packages

- 6. Define a Custom Element

- 7. Use Future-Based APIS

- 8. Use Streams for Data

- 9. Fetch Data Dynamically

- 10. Get Input from a Form

- 11. Use Indexed DB

- 12. Write Command-line Apps



Write Command-Line Apps

명령형 앱 작성하기.

An introduction to standalone apps
독립형 앱 소개

This tutorial teaches you how to build command-line apps and shows you a few small command-line applications. These programs use resources that most command-line applications need, including the standard output, error, and input streams, command-line arguments, files and directories, and more.

이번 튜토리얼에서는 어떻게 명령줄 앱을 만드는지를 가르쳐 주고 몇 개의 작은 명령줄 어플리케이션을 보여줄 것입니다. 이 프로그램들은 대부분의 명령줄 어플리케이션이 필요로 하는, 예를 들면 표준 출력, 오류 및 입력 스트림, 명령 줄 인수, 파일과 디렉토리 등등의 자원을 이용할 것입니다.

Running an app with the standalone Dart VM
독립형 Dart VM으로 앱 실행하기

To run a command-line app, you need the Dart VM (dart), which comes in the Dart SDK download. (If you downloaded Dart Editor, you already have the Dart VM.)

명령줄 앱을 실행하기 위해서,  Dart VM 이 필요합니다.Dart VM 에 Dart SDK download 다운할 수 있습니다.(만약 Dart 에디터가 다운로드 되어 있다면, 이미 Dart VM이 깔려 있는 것입니다.)

If you installed the Dart download in a directory called ~/myDartDownload, you can find dart in~/myDartDownload/dart-sdk/bin.

~/myDartDownload 디렉토리에 Dart를 인스톨했다면 ~/myDartDownload/dart-sdk/bin 에서 dart 를 찾을 수 있습니다.The path to the Dart VM

By putting this directory in your PATH you can refer to the dart command and other commands, such as the dart analyzer, by name.

이 디렉토리에 가면 dart 명령어와 dart analyzer과  다른 명령어를 볼 수 있습니다.

Let’s run a small program.

작은 프로그램을 만들어 봅시다.

  1. Create a file called helloworld.dart that contains this code:
    아래의 코드를 포함하는
    helloworld.dart 파일을 만드세요.

  2. void main() {
     print
    ('Hello, World!');
    }

  3. In the directory that contains the file you just created, run the program with the command as shown by the highlighted text.
    금방 만든 파일이 있는 디렉토리에서 아래에 있는 명령줄을 쳐서 프로그램을 실행하세요.

  4. % dart helloworld.dart
    Hello, World!
    %

The Dart VM supports many options. Use dart --help to see commonly used options. Use dart --verbose to see all options.

Dart VM은 많은 옵션을 지원합니다. 흔히 쓰이는 옵션을 보려면 dart --help 를 사용하세요. 모든 옵션을 보려면 dart --verbose 을 사용하세요.

Review briefly the dcat example code
dcat 예제 코드 쉽게 리뷰하기

Take a quick look at the code for a small sample called dcat, which displays the contents of any files listed on the command line. This program uses various classes, functions, and properties available to command-line apps. This tutorial goes into detail about this app in the following sections. For a brief look now, hover over the highlighted code below for explanations.

명령행 줄에 리스트된 모든 파일의 내용을 보여주는 dcat 라고 하는 작은 샘플 코드를 간단히 살펴봅시다. 이 프로그램은 명령행 앱에서 사용할 수 있는 다양한 클래스, 함수, 그리고 프로퍼티스들을 사용합니다. 이번 튜토리얼은 다음의 섹션에서 이 앱의 자세한 정보를 알아볼 것입니다. 지금 아래의 간단한 코드에서,  설명을 보려면 아래의 강조된 코드에 마우스 커서를 올려놓으세요. (실제 모습을 보려면 https://www.dartlang.org/docs/tutorials/cmdline/#dcat-code 을 참고)

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:args/args.dart';

const LINE_NUMBER = 'line-number';
var NEWLINE = '\n';

ArgResults argResults
;

void main(List<String> arguments) {
 
final parser = new ArgParser()
     
..addFlag(LINE_NUMBER, negatable: false, abbr: 'n');

 argResults = parser.parse(arguments);
 List
<String> paths = argResults.rest;

 dcat
(paths, argResults[LINE_NUMBER]);
}

Future dcat
(List<String> paths, bool showLineNumbers) {
 
if (paths.isEmpty) {
   
// No files provided as arguments. Read from stdin and print each line.
   
return stdin.pipe(stdout);
 
} else {
   
return Future.forEach(paths, (path) {
     
int lineNumber = 1;
    
 Stream<List<int>> stream = new File(path).openRead();
     
return stream
        
 .transform(UTF8.decoder)
         
.transform(const LineSplitter())
        
 .listen((line) {
           
if (showLineNumbers) {
             stdout
.write('${lineNumber++} ');
           
}
           stdout
.writeln(line);
         
}).asFuture().catchError((_) => _handleError(path));
   
});
 
}
}

_handleError
(String path) {
 FileSystemEntity.isDirectory(path).then((isDir) {
   
if (isDir) {
     print
('error: $path is a directory');
   
} else {
     print
('error: $path not found');
   
}
 
});
 exitCode = 2;
}
Parsing command-line arguments
명령줄 인자 파싱하기

The args package, a software bundle that contains a library of Dart code, provides parser support for transforming raw command-line arguments into a set of options, flags, and additional values. Import the library as follows:

Dart 코드의 라이브러리를 포함하고 있는 소프웨어 번들인,  args 패키지는 옵션, 플래그, 그리고 추가적인 값의 세트에 원시 명령 줄 인자를 변환하기 위한 파서를 제공합니다. 아래처럼 라이브러리를 추가하세요.

import 'package:args/args.dart';

The args library contains two classes:

args 라이브러리는 2개의 클래스가 있습니다.

Library

Description

ArgParser

A class that parses command-line arguments
명령줄 인자를 파싱하는 클래스

ArgResults

The result of parsing command-line arguments using ArgParser.
ArgParser 를 이용해서 명령줄 인자를 파싱한 결과

Let’s take a look at the dcat sample, which uses ArgParser and ArgResults to parse and store its command-line arguments.

명령줄 인자를 파싱하고 저장하기 위해 ArgParser과 ArgResults를 사용하고 있는 dcat 샘플을 한 번 살펴봅시다.

  1. Copy the sample file from the github repo: dcat.dart.
    github 저장소에서 샘플 파일을 카피하세요:
    dcat.dart.

  2. Run the program from the command line as shown by the highlighted text
    아래에 보이는 강조 표시된 텍스트처럼 프로그램을 실행하세요.

  3. $ dart dcat.dart -n quotes.txt
    1 Be yourself. Everyone else is taken. -Oscar Wilde
    2 Don't cry because it's over, smile because it happened. -Dr. Seuss
    3 You only live once, but if you do it right, once is enough. -Mae West
    ...

  4. The program displays the contents of the source code file and preceeds each line with a line number.
    프로그램은 소스코드 파일의 내용과 라인 넘버를 보여줍니다.

The following diagram shows how the dcat command line used above is parsed into the ArgResults object.

아래의 그림은 dcat 명령줄 프로그램이 어떻게 ArgResults  객체를 파싱하는지 보여줍니다.ArgsParser parses command-line arguments

You can access flags and options by name, treating the ArgResults object like a Map. You can access other values with properties such as rest.

이름으로 플래그와 옵션에 접근할 수 있고 Map 객체처럼 ArgResults  객체를 사용할 수 있습니다. rest 와 같은 프로퍼티스를 이용해서 다른 값에도 접근할 수가 있습니다.

Here’s the code from dcat that deals with command-line arguments:

명령줄 인자를 처리하는 dcat 의 코드가 아래에 있습니다.
...
ArgResults argResults;

void main(List<String> arguments) {
 
final parser = new ArgParser()
    
 ..addFlag(LINE_NUMBER, negatable: false, abbr: 'n');

 argResults
= parser.parse(arguments);
 List
<String> paths = argResults.rest;

 dcat
(paths, argResults[LINE_NUMBER]);
}
...

The API docs for the args library provide detailed information to help you use ArgsParser and ArgResults classes.

args 라이브러리의 API docs 는 당신이 ArgsParser 과 ArgResults 클래스에 대한 자세한 정보를 제공합니다.

Reading and writing with stdin, stdout, and stderr
stdin, stdout 그리고 stderr 을 이용해서 읽고 쓰기

Like other languages, Dart has standard output, standard error, and standard input streams. The standard I/O streams are defined at the top level of the dart:io library,

다른 언어들 처럼, Dart도 표준 출력, 표준 에러, 그리고 표준 입력 스트림을 가지고 있습니다. 표준 I/O 스트림은 최상위 라이브러리인 dart:io 에 정의되어 있습니다.

Stream

Description

stdout

The standard output

stderr

The standard error

stdin

The standard input

Import the dart:io library as follows:

아래처럼 dart:io 라이브러리를 추가하세요.

import 'dart:io';

Only command-line applications, not web applications, can use the dart:io library.

dart:io  라이브러리는, 웹 어플리케이션은 안되고, 명령줄행 어플리케이션에만 사용할 수 있습니다.

stdout

Here’s the code from the dcat program that writes the line number to the stdout (if the -n flag is set) followed by the line from the file.

-n 플래그가 설정되어 있다면, 파일에서  라인을 읽어서 stdout 에 라인넘버를 출력해주는 dcat 프로그램 소스가 있습니다.

if (showLineNumbers) {
 
stdout.write('${lineNumber++} ');
}
stdout.writeln(line);

The write() and writeln() methods take an object of any type, convert it to a string, and print it. The writeln() method also prints a newline character. dcat uses the write() method to print the line number so the line number and the text appear on the same line.

write()writeln() 메소드는 모든 타입의 객체를 스트링으로 변환하고 출력할 수 있습니다. writeln() 메소드는 또한 줄바꿈 문자를 출력합니다. dcat 은 라인넘버를 출력하기 위해서 write() 메소드를 사용하기 때문에 라인넘버와 본문 내용이 같은 줄에 나타납니다.

You can also use the writeAll() method to print a list of objects, or use addStream() to asynchronously print all of the elements from a stream.

객체들의 리스트를 출력하기 위해 writeAll() 메소드를 사용하거나, 스트림의 모든 요소를 비동기적으로 출력하기 위해 addStream() 메소드를 사용할 수 있습니다.

stdout provides more functionality than the print() function. For example, you can display the contents of a stream with stdout. However, you must use print() instead of stdout for programs that are converted to and run in JavaScript.

stdoutprint() 보다 좀 더 많은 기능을 제공합니다. 예를 들어, stdout으로 스트림의 내용을 표시할 수 있습니다. 그러나, 자바스크립트로 변환되고 실행되는 프로그램에서는 stdout 대신에 print() 을 반드시 사용해야 합니다.

stderr

Use stderr to write error messages to the console. The standard error stream has the same methods as stdout, and you use it in the same way. Although both stdout and stderr print to the console, their output is separate and can be redirected or piped at the command line or programmatically to different destinations.

콘솔에 에러 메시지를 쓰려면 stderr 를 사용하세요. 표준 에러 스트림은 stdout 과 같은 메소드를 가지고 있고, 같은 방법으로 사용할 수 있습니다. stdoutstderr  둘다 콘솔에 출력하는 것이지만,  그 둘은 분리되어져 있고, 명령줄이나 다른 목적지에 프로그램적으로 리다이렉트 또는 파이프되어 질 수 있습니다.

This code from dcat prints an error message if the user tries to list a directory or if the file is not found.

사용자가 디렉토리를 볼려고 하거나 파일이 없을경우에,  dcat 코드는 에러 메시지를 출력합니다.

if (isDir) {
 
stderr.writeln('error: $path is a directory');
} else {
 
stderr.writeln('error: $path not found');
}

stdin

The standard input stream typically reads data synchronously from the keyboard, although it can read asynchronously and it can get input piped in from the standard output of another program.

표준 입력 스트림은 비동기로 읽고 다른 프로그램의 표준 출력에 파이프 되어 있더라도 일반적으로 키보드에서 동기적으로 데이터를 읽습니다.

Here’s a small program that reads a single line from stdin:

아래는 stdin 으로 한줄을 읽는 작은 프로그램 입니다.

import 'dart:io';

void main() {
 stdout
.writeln('Type something');
 
String input = stdin.readLineSync();
 stdout
.writeln('You typed: $input');
}

The readLineSync() method reads text from the standard input stream, blocking until the user types in text and presses return. This little program prints out the typed text.

readLineSync() 메소드는 사용자가 키보드로 텍스트를 타이핑하고 엔터를 누룰때 까지 표준 입력 스트림에서 텍스트를 읽습니다. 이 작은 프로그램은 타이핑된 텍스트를 출력합니다.

In the dcat program, if the user does not provide a filename on the command line, the program instead reads synchronously from stdin using the pipe() method.

dcat 프로그램에서, 사용자가 명령줄에서 파일 이름을 제공하지 않으면, 프로그램은 파일 대신에 pipe() 메소드를 사용해서 표준 입력에서 비동기적으로 읽습니다.

return stdin.pipe(stdout);

In this case, the user types in lines of text and the program copies them to stdout. The user signals the end of input by typing <ctl-d>.

이 경우에, 사용자는 텍스트 한 줄을 타이핑하고 프로그램은 표준 출력에 그것들을 카피합니다. 사용자는 입력이 끝났다는 것을 알리기 위해 <ctl-d> 을 입력하여 신호를 줍니다.

$ dart dcat.dart
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
...

Getting info about a file
파일에 대한 정보 얻기

The FileSystemEntity class in the dart:io library provides properties and static methods that help you inspect and manipulate the file system.

dart:io 라이브러리에 있는 FileSystemEntity  클래스는 파일 시스템을 검사하고 조작할 수 있도록 하는 프로퍼티스와 정적 메소드를 제공합니다.

For example, if you have a path, you can determine whether the path is a file, a directory, a link, or not found by using the type() method from the FileSystemEntity class. Because the type() method accesses the file system, it performs the check asynchronously within a Future.

예를 들어, 당신이 경로(path)가 있다면, 당신은 FileSystemEntity 클래스의 type() 메소드를 사용해서 그 경로(paht)가 파일인지, 디렉토리인지, 링크인지, 아니면 아예 없는 것인지를 알 수 있습니다. type() 메소드는 파일 시스템에 접근 할 수 있기 때문에, Future 를 사용해서 비동기적으로 체크할 수 있습니다.

The following code from the dcat example uses FileSystemEntity to determine if the path provided on the command line is a directory. The Future returns a boolean that indicates if the path is a directory or not.

dcat 예제의 아래 코드는 명령중에서 제공된 경로(path)가  디렉토리인지를 알아보기 위해서 FileSystemEntity 를 사용하고 있습니다. Future는 디렉토리가 맞는지 아닌지를 알려주기 위해서 불리언 값을 리턴합니다.

FileSystemEntity.isDirectory(path).then((isDir) {
 
if (isDir) {
   stderr
.writeln('error: $path is a directory');
 
} else {
   stderr
.writeln('error: $path not found');
 
}
 exit
(2);
});

Other interesting methods in the FileSystemEntity class include isFile(), exists(), stat(), delete(), and rename(), all of which also use a Future to return a value.

FileSystemEntity 클래스에서 다른 흥미있는 메소드에는  isFile(), exists(), stat(), delete(),  과 rename() 이것이 있습니다. 이 메소드 모두는 값을 반환하는 Future 를 사용합니다.

FileSystemEntity is the superclass for the File, Directory, and Link classes.

FileSystemEntity 은 File, Directory 와 Link 클래스의 상위 클래습니다.

Reading a file
파일 읽기

dcat opens each file listed on the command line with the openRead() method, which returns a stream. The listen()method registers a callback function that runs when data becomes available on the stream. The callback function writes that data to stdout.

dcat 은 스트림을 반환하는 openRead() 메소드를 사용해서 명령줄 행에 리스트된 각각의 파일들을 엽니다.  listen() 메소드는 데이터가 스트림에서 이용 가능하게  되는 시점에 실행되는 콜백함수를 등록합니다. 콜백 함수는 데이터를 표준출력에 씁니다.

return Future.forEach(paths, (path) {
 
int lineNumber = 1;
 Stream
<List<int>> stream = new File(path).openRead();

 
return stream
     
...
     
.listen((line) {
       if (showLineNumbers) {
         stdout.write('${lineNumber++} ');
       }
       stdout.writeln(line);
     })
.asFuture()
         
.catchError((_) => _handleError(path));
});

The following shows the rest of the code, which uses two decoders that transform the data before the listen()callback function runs. The UTF8 decoder converts the data into Dart strings. LineSplitter splits the data at newlines.

아래에는 listen() 콜백 함수가 실행되기 전에 데이터를 변형하기 위해 2개의 decoder를 사용하는 코드입니다. UTF-8 디코더는 데이터를 Dart 문자열로 변환합니다. LineSpliter 는 새로운 줄로 데이터를 분리합니다.

return Future.forEach(paths, (path) {
 
int lineNumber = 1;
 Stream
<List<int>> stream = new File(path).openRead();

 
return stream
     
.transform(UTF8.decoder)
     .transform(const LineSplitter())

     
.listen((line) {
       
if (showLineNumbers) {
         stdout
.write('${lineNumber++} ');
       
}
       stdout
.writeln(line);
     
}).asFuture()
         
.catchError((_) => _handleError(path));
});

The dart:convert library contains these and other data converters, including one for JSON. To use these converters you need to import the dart:convert library:

dart:convert 라이브러리는 이런 것들과 JSON에 대한 것들을 포함하는 다른 컨버터도 포함하고 있습니다. 당신이 필요로 하는 컨버터들을 사용하기 위해서는 dart:convert 라이브러리를 추가하세요.

import 'dart:convert';

Writing a file
파일 쓰기

The easiest way to write text to a file is to create a File object and use the writeAsString() method:

파일에 텍스트를 쓰는 가장 쉬운 방법은 File 객체를 만들고 writeAsString() 메소드를 사용하는 것입니다.

File quotesFile = new File('quotes.txt');
String stronger = 'That which does not kill us makes us stronger. -Nietzsche';

quotesFile
.writeAsString(stronger, mode: FileMode.APPEND)
   
.then((_) { print('Data written.'); });

The writeAsString() method writes the data asynchronously via a Future. It opens the file before writing and closes the file when done. To append data to an existing file, you can use the optional parameter mode and set its value to FileMode.APPEND. Otherwise, the mode is FileMode.WRITE and the previous contents of the file, if any, are overwritten.

writeAsString() 메소드는 Future를 사용해서 비동기적으로 데이터를 씁니다. 이 메소드는 쓰기전에 파일을 열고 다 쓴 후에 파일을 닫습니다. 존재하는 파일에 데이터를 덧붙이기 위해서는 추가 옵션 mode 를 사용할 수 있고 추가 옵션 mode의 값을 FileMode.APPEND 로 설정합니다. 그렇지 않으면, mode  는FileMode.WRITEE가 되고 파일에 있는 이전의 내용들을 모두 덮어쓰게 됩니다.

If you want to write more data, you can open the file for writing. The openWrite() method returns an IOSink (the same type as stdin and stderr). You can continue to write to the file until done, at which time, you must close the file. The close() method is asynchronous and returns a Future.

더 많은 데이터를 쓰고 싶다면, 쓰기 위해서 그 파일을 열 수 있습니다. openWrite()메소드는 IOSink(stdin 과 stderr과 같은 타입).를 리턴합니다. 작업이 완료될때까지 파일에 쓰기를 계속 할수 있습니다. 그리고 작업이 완료되면 반드시 그 파일을 닫아야 합니다. close() 메소드는 비동기적이고 Future 를 반환합니다.

IOSink quotes = new File('quotes.txt').openWrite(mode: FileMode.APPEND);

quotes
.write('A woman is like a tea bag; ');
quotes
.write("you never know how strong it is until it's in hot water.");
quotes
.writeln(" -Eleanor Roosevelt");
quotes
.close().then((_) { print('done'); } );

Getting environment information
환경 정보 가져오기.

Use the Platform class to get information about the machine and OS that the program is running on. Note: Use the Platform class from the dart:io library, not from the dart:html library.

프로그램이 실행되고 있는 OS와 기계에 대한 정보를 얻고 싶으면 Platform 클래스를 사용하세요. 참고: dart:io 라이브러리에 있는 Platform  클래스를 사용하세요. dart:html 에 있는 라이브러리에 있는 것을 사용하면안됩니다.

Platform.environment provides a copy of the environment variables in an immutable map. If you need a mutable map (modifiable copy) you can use  Map.from(Platform.environment).

Platform.environment 은 불가변의 맵에서 환경 변수의 복사본을 제공합니다. 당신이 가변의 맵(수정이 가능한)이 필요하다면  Map.from(Platform.environment)를 사용할 수 있습니다.

Map environmentVars = Platform.environment;

print
('PWD = ${environmentVars["PWD"]}');
print
('LOGNAME = ${environmentVars["LOGNAME"]}');
print
('PATH = ${environmentVars["PATH"]}');

Platform provides other useful properties that give information about the machine, OS, and currently running program. For example:

Platfrom 은 프로그램이 실행되고 있는 OS와 기계에 대해서 다른 유용한 정보도 제공합니다. 예를 들어:

  • Platform.isMacOS()

  • Platform.numberOfProcessors

  • Platform.script.path

Setting exit codes
exit 코드 설정하기

The dart:io library defines a top-level property, exitCode, that you can change to set the exit code for the current invocation of the Dart VM. An exit code is a number passed from the Dart program to the parent process to indicate the success, failure, or other state of the execution of the program.

dart:io 라이브러리는 exitCode 라고 하는 최상위 프러퍼티를 제공합니다. exitCode는 현재 호출된 Dart VM의 exit 코드의 설정을 변경할 수 있습니다.exit 코드는 실행프로그램의 성공, 실패, 또는 다른 상태를 나타내기 위해 Dart 프로그램에서 상위 프로세스에게 전달된 숫자입니다.

The dcat program sets the exit code in the _handleError() function to indicate that an error occcurred during execution.

dcat 프로그램 실행하는 동안 발생된 에러를 나타내기 위해서 _handleError() 함수에서 exit 코드를 설정합니다.

_handleError(String path) {
 FileSystemEntity
.isDirectory(path).then((isDir) {
   
if (isDir) {
     stderr
.writeln('error: $path is a directory');
   
} else {
     stderr
.writeln('error: $path not found');
   
}
   
exitCode = 2;
 
});
}

An exit code of 2 indicates that the program encountered an error.

exit 코드 2는 프로그램이 에러가 발생했다는 것을 나타냅니다.

An alternative to using exitCode is to use the top-level exit() function, which sets the exit code and quits the program immediately. For example, the _handleError() function could call exit(2) instead of setting exitCode to 2, but exit()would quit the program and it might not process all of the files on the command line.

exitCode 를 사용하는 대신에, exit 코드를 설정하고 즉시 프로그램을 종료하는, 최상위 함수인 exit() 를 사용하는 것입니다. 예를 들어, _handleError() 함수는  exitCode 에 2 를 설정하는 대신에 exit(2)를 호출 할 수도 있습니다. 하지만, exit() 는 프로그램을 종료하고 명령줄에서의 모든 파일을 처리하지 않을 수 있습니다.

Generally speaking, you are better off using the exitCode property, which sets the exit code but allows the program to continue through to its natural completion.

일반적으로 말하자면,  프로그램이 자연적으로 완료될 수 있도록 하는 exit 코드를 설정하는, exitCode 프로퍼티를 사용하는것이 더 좋습니다.

Although you can use any number for an exit code, by convention, the codes in the table below have the following meanings:

exit 코드에 어떤 숫자라도 사용할 수 있지만, 규칙에 따라서 아래 테이블에 있는 코드들은 다음을 의미합니다.

Code

Meaning

0

Success

1

Warnings

2

Errors

Summary

This tutorial described some basic API found in these classes from the dart:io library:

이번 튜토리얼에서는 dart:io 라이브러리에 있는 아래의 클래스들의 기본 API에 대해서 설명했습니다.

API

Description

IOSink

Helper class for objects that consume data from streams.
스트림에서 데이터를 소비하는 헬퍼 클래스

File

Represents a file on the native file system
네이티브 파일 시스템에 있는 파일을 나타냄

Directory

Represents a directory on the native file system
네이티브 파일 시스템에서 디렉토리를 나타냄.

FileSystemEntity

Superclass for File and Directory
File과 Directory의 슈퍼 클래스

Platform

Provides information about the machine and operating system
기계와 OS에 대한 정보 제공

stdout

The standard output

stderr

The standard error

stdin

The standard input

exitCode

Sets the exit code

exit()

Sets the exit code and quits

In addition, this tutorial covers two classes that help with command-line arguments:

추가적으로, 이번 튜토리얼은 명령줄 행 인자에서 사용할 수 있는 2개의 클래스도 있습니다.

Class

Description

ArgParser

A class that transforms a list of raw arguments and into a set of options, flags, and remaining values.
원시 인자의 리스트와 옵션, 플래그, 그리고 남아있는 값들의 세트를 변형하는 클래스

ArgResults

The result of parsing raw command line arguments using ArgParser.
ArgParser를 사용해서 원시 명령줄 인자를 파싱한 결과

Other resources
다른 자원

Check out the Command-line Apps Programmers’ Guide to find more resources related to writing command-line apps.

명령줄 앱을 작성하는데 관련된 더 많은 자원을 찾는다면 Command-line Apps Programmers’ Guide 을 참고 하세요.

See the Dartiverse Search walkthrough for an example of another kind of command-line app: an HTTP server.

명령줄 앱의 다른 종류의 예제를 원하면 Dartiverse Search walkthrough  을 보세요.

Refer to the API docs for dart:io, dart:async, dart:convert, and the args package for more classes, functions, and properties.

좀 더 많은 클래스, 함수, 프로퍼티들을 알고 싶으면 dart:io, dart:async, dart:convert, 과 args 팩키지를 위한 API 문서를 참고하세요.

What next?
다음은?

Try the Weigh Anchor: Deploy a Server and App code lab to learn how to deploy your project to the Heroku hosting service.

Heroku 호스팅 서비스에 당신의 프로젝트를 어떻게 디플로이 하는지 배우고 싶으시면 Weigh Anchor: Deploy a Server and App 를 보세요.

The Get Input from a Form tutorial features a client-server. The code for the server, which uses CORS headers and handles POST requests, is explained in detail.

Get Input from a Form  튜토리얼은 클라이언트-서버를 설명합니다. CORS 헤더를 사용하고 POST 요청을 처리하는 서버쪽 코드가 자세히 설명되어져 있습니다.

300x250

'개발 > dart' 카테고리의 다른 글

"나의 로또" 개인정보 처리 방침  (0) 2024.02.06
11, Use Indexed DB  (0) 2014.03.14
10. Get Input from a Fom  (0) 2014.03.12
9. Fetch Data Dynamically  (0) 2014.03.04
8. Use Streams for Data  (0) 2014.03.02

댓글