🔥 명령어 숨기기

98자
1분

명령줄 인터페이스 일부로 모든 명령어를 표시하고 싶지 않을 수도 있습니다. 명령어를 보이지 않게 만들려면(그러나 여전히 사용할 수 있음) CommandConfiguration 이니셜라이저에 shouldDisplay: false를 전달합니다.

lecture image

아래와 같이 Child 명령어에 shouldDisplay: false를 추가하여 간단하게 숨길 수 있습니다:

swift
struct Parent: ParsableCommand {
    static let configuration = CommandConfiguration(
        subcommands: [Child.self],
        helpNames: [.long, .customShort("?")])
 
    struct Child: ParsableCommand {
        static let configuration = CommandConfiguration(
            shouldDisplay: false
        )
 
        @Option(name: .shortAndLong, help: "The host the server will run on.")
        var host: String
    }
}
 
swift
struct Parent: ParsableCommand {
    static let configuration = CommandConfiguration(
        subcommands: [Child.self],
        helpNames: [.long, .customShort("?")])
 
    struct Child: ParsableCommand {
        static let configuration = CommandConfiguration(
            shouldDisplay: false
        )
 
        @Option(name: .shortAndLong, help: "The host the server will run on.")
        var host: String
    }
}
 

이제 Child 명령어는 Parent 명령어 도움말에는 표시되지 않지만, 여전히 parent child --host <host>와 같이 직접 실행할 수 있습니다.

YouTube 영상

채널 보기
13편, 인덱스가 많으면 왜 느려질까? 쓰기 증폭과 인덱스 튜닝의 이해
Trie 자료구조 완전 정복 - 개념부터 시각화까지 | Trie 자료구조 이야기
숫자 하나가 AI 모델의 운명을 바꾼다? | 선형대수학
숫자 하나가 AI 모델의 운명을 바꾼다? | 선형대수학
벡터의 정의와 덧셈 연산 | 선형대수학
AI를 위한 선형대수학 - 소개 | 선형대수학
스칼라 곱셈과 내적의 기하학적 의미 | 선형대수학
내적의 기하학적 의미와 코사인 유사도 원리 | 선형대수학