🔥 소개

166자
2분

사용자와 스스로를 돕기 위해 매개변수, 옵션 및 플래그에 대한 풍부한 도움말을 제공합시다. @Argument, @Option 또는 @Flag를 선언할 때 help 매개변수로 문자열 리터럴을 전달하여 도움말 텍스트를 제공할 수 있습니다.

swift
struct Example: ParsableCommand {
    @Flag(help: "Display extra information while processing.")
    var verbose = false
 
    @Option(help: "The number of extra lines to show.")
    var extraLines = 0
 
    @Argument(help: "The input file.")
    var inputFile: String?
}
 
swift
struct Example: ParsableCommand {
    @Flag(help: "Display extra information while processing.")
    var verbose = false
 
    @Option(help: "The number of extra lines to show.")
    var extraLines = 0
 
    @Argument(help: "The input file.")
    var inputFile: String?
}
 

이런 문자열은 기본적으로 -h 또는 --help 플래그로 트리거되는 자동 생성된 도움말 화면에서 볼 수 있죠.

text
% example --help
USAGE: example [--verbose] [--extra-lines <extra-lines>] <input-file>

ARGUMENTS:
  <input-file>            The input file.

OPTIONS:
  --verbose               Display extra information while processing.
  --extra-lines <extra-lines>
                          The number of extra lines to show. (default: 0)
  -h, --help              Show help information.
text
% example --help
USAGE: example [--verbose] [--extra-lines <extra-lines>] <input-file>

ARGUMENTS:
  <input-file>            The input file.

OPTIONS:
  --verbose               Display extra information while processing.
  --extra-lines <extra-lines>
                          The number of extra lines to show. (default: 0)
  -h, --help              Show help information.

이렇게 제공되는 도움말은 사용자가 명령줄 도구를 더 쉽게 이해하고 사용할 수 있도록 돕습니다. 개발자 역시 이러한 도움말을 통해 인터페이스를 더 잘 문서화하고 관리할 수 있어요. help 매개변수의 문자열은 간결하면서도 명확해야 합니다. 해당 인자나 옵션의 목적과 동작을 잘 설명해야 하죠. 기본값이 있다면 이를 명시하는 것도 좋은 방법입니다.

YouTube 영상

채널 보기
7편, 파이썬으로 구현하는 B-Tree
Trie(트라이) 자료구조 원리와 파이썬 클래스 설계 및 구현 | Trie 자료구조 이야기
숫자 하나가 AI 모델의 운명을 바꾼다? | 선형대수학
Trie 자료구조 파이썬 구현: Search와 Starts With 연산 | Trie 자료구조 이야기
우리가 매일 쓰는 맞춤법 검사기와 라우터 속에 숨겨진 알고리즘은? | Trie 자료구조 이야기
Trie 자료구조 완전 정복 - 개념부터 시각화까지 | Trie 자료구조 이야기
AI는 왜 수백 차원의 벡터를 사용할까? 고차원 공간과 행렬 | 선형대수학
내적의 기하학적 의미와 코사인 유사도 원리 | 선형대수학