mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
Eliminate magic numbers.
Partial #592 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
fcf8ba29f6
commit
ee28af69df
3 changed files with 9 additions and 4 deletions
|
@ -10,6 +10,8 @@ import CommerceKit
|
|||
import PromiseKit
|
||||
import StoreFoundation
|
||||
|
||||
private let timeout = 30.0
|
||||
|
||||
extension ISStoreAccount: StoreAccount {
|
||||
static var primaryAccount: Promise<ISStoreAccount> {
|
||||
if #available(macOS 10.13, *) {
|
||||
|
@ -20,7 +22,7 @@ extension ISStoreAccount: StoreAccount {
|
|||
seal.fulfill(storeAccount)
|
||||
}
|
||||
},
|
||||
after(seconds: 30)
|
||||
after(seconds: timeout)
|
||||
.then {
|
||||
Promise(error: MASError.notSignedIn)
|
||||
}
|
||||
|
@ -79,7 +81,7 @@ extension ISStoreAccount: StoreAccount {
|
|||
|
||||
return race(
|
||||
signInPromise,
|
||||
after(seconds: 30)
|
||||
after(seconds: timeout)
|
||||
.then {
|
||||
Promise(error: MASError.signInFailed(error: nil))
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ struct ProgressState {
|
|||
let phase: String
|
||||
|
||||
var percentage: String {
|
||||
// swiftlint:disable:next no_magic_numbers
|
||||
String(format: "%.1f%%", floor(percentComplete * 1000) / 10)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ enum SearchResultFormatter {
|
|||
/// - includePrice: Indicates whether to include prices in the output
|
||||
/// - Returns: Multiline text output.
|
||||
static func format(results: [SearchResult], includePrice: Bool = false) -> String {
|
||||
// find longest appName for formatting, default 50
|
||||
let maxLength = results.map(\.trackName.count).max() ?? 50
|
||||
guard let maxLength = results.map(\.trackName.count).max() else {
|
||||
return ""
|
||||
}
|
||||
|
||||
var output = ""
|
||||
|
||||
for result in results {
|
||||
|
|
Loading…
Reference in a new issue