Skip to content

Declare Hashable conformance for ArgumentVisibility #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//===----------------------------------------------------------------------===//

/// Visibility level of an argument's help.
public struct ArgumentVisibility {
public struct ArgumentVisibility: Hashable {
/// Internal implementation of `ArgumentVisibility` to allow for easier API
/// evolution.
internal enum Representation {
Expand Down
16 changes: 11 additions & 5 deletions Sources/ArgumentParserTestHelpers/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//

@testable import ArgumentParser
import ArgumentParser
import ArgumentParserToolInfo
import XCTest

Expand Down Expand Up @@ -122,15 +122,18 @@ public func AssertHelp<T: ParsableArguments>(
let flag: String
let includeHidden: Bool

switch visibility.base {
switch visibility {
case .default:
flag = "--help"
includeHidden = false
case .hidden:
flag = "--help-hidden"
includeHidden = true
case .private:
XCTFail("Should not be called.")
XCTFail("Should not be called.", file: file, line: line)
return
default:
XCTFail("Unrecognized visibility.", file: file, line: line)
return
}

Expand Down Expand Up @@ -158,13 +161,16 @@ public func AssertHelp<T: ParsableCommand, U: ParsableCommand>(
) {
let includeHidden: Bool

switch visibility.base {
switch visibility {
case .default:
includeHidden = false
case .hidden:
includeHidden = true
case .private:
XCTFail("Should not be called.")
XCTFail("Should not be called.", file: file, line: line)
return
default:
XCTFail("Unrecognized visibility.", file: file, line: line)
return
}

Expand Down