mirror of
https://github.com/mas-cli/mas
synced 2025-03-06 23:57:21 +00:00
Improve mas config
:
- Reorder `mas config` output. - Set `Package.installMethod` from `script/lint` & `script/test`. - Consolidate `sysctl` value reading for `mas config`. Partial #701 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
3cc4cf5f7a
commit
6f7d6aca49
3 changed files with 8 additions and 34 deletions
|
@ -29,19 +29,19 @@ extension MAS {
|
|||
print(
|
||||
"""
|
||||
mas ▁▁▁▁ \(Package.version)
|
||||
arch ▁▁▁ \(configStringValue("hw.machine"))
|
||||
from ▁▁▁ \(Package.installMethod)
|
||||
origin ▁ \(Package.gitOrigin)
|
||||
rev ▁▁▁▁ \(Package.gitRevision)
|
||||
swift ▁▁ \(Package.swiftVersion)
|
||||
driver ▁ \(Package.swiftDriverVersion)
|
||||
swift ▁▁ \(Package.swiftVersion)
|
||||
region ▁ \(Storefront.isoRegion?.alpha2 ?? unknown)
|
||||
macos ▁▁ \(
|
||||
ProcessInfo.processInfo.operatingSystemVersionString.dropFirst(8)
|
||||
.replacingOccurrences(of: "Build ", with: "")
|
||||
)
|
||||
mac ▁▁▁▁ \(macModel())
|
||||
cpu ▁▁▁▁ \(cpuBrandString())
|
||||
arch ▁▁▁ \(architecture())
|
||||
mac ▁▁▁▁ \(configStringValue("hw.product"))
|
||||
cpu ▁▁▁▁ \(configStringValue("machdep.cpu.brand_string"))
|
||||
"""
|
||||
)
|
||||
if markdown {
|
||||
|
@ -51,34 +51,8 @@ extension MAS {
|
|||
}
|
||||
}
|
||||
|
||||
private func macModel() -> String {
|
||||
var name = [CTL_HW, HW_MODEL]
|
||||
|
||||
var size = 0
|
||||
guard sysctl(&name, u_int(name.count), nil, &size, nil, 0) == 0 else {
|
||||
perror("sysctl")
|
||||
return unknown
|
||||
}
|
||||
|
||||
var buffer = [CChar](repeating: 0, count: size)
|
||||
guard sysctl(&name, u_int(name.count), &buffer, &size, nil, 0) == 0 else {
|
||||
perror("sysctl")
|
||||
return unknown
|
||||
}
|
||||
|
||||
return String(cString: buffer)
|
||||
}
|
||||
|
||||
private func cpuBrandString() -> String {
|
||||
configValue("machdep.cpu.brand_string")
|
||||
}
|
||||
|
||||
private func architecture() -> String {
|
||||
configValue("hw.machine")
|
||||
}
|
||||
|
||||
private func configValue(_ name: String) -> String {
|
||||
var size = 0
|
||||
private func configStringValue(_ name: String) -> String {
|
||||
var size = MemoryLayout<Int32>.size
|
||||
guard sysctlbyname(name, nil, &size, nil, 0) == 0 else {
|
||||
perror("sysctlbyname")
|
||||
return unknown
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
printf $'==> 🚨 Linting mas %s\n' "$(script/version)"
|
||||
|
||||
script/generate_package_swift
|
||||
script/generate_package_swift lint
|
||||
|
||||
for linter in git markdownlint periphery shellcheck swift-format swiftformat swiftlint yamllint; do
|
||||
if ! command -v "${linter}" >/dev/null; then
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
printf $'==> ✅ Testing mas %s\n' "$(script/version)"
|
||||
|
||||
script/generate_package_swift
|
||||
script/generate_package_swift test
|
||||
|
||||
script -q /dev/null swift test "${@}" |
|
||||
(grep -vxE $'Test Suite \'.+\' (?:started|passed) at \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3}\\.?\\r|Test Case \'-\\[.+\\]\' (?:started|passed \\(\\d+\\.\\d+ seconds\\))\\.\\r|\\t Executed \\d+ tests?, with 0 failures \\(0 unexpected\\) in \\d+\\.\\d+ \\(\\d+\\.\\d+\\) seconds\\r' || true)
|
||||
|
|
Loading…
Add table
Reference in a new issue