Skip to content

Commit 6d0251c

Browse files
committed
added --show-dynamic option to 'get-uti'
1 parent 390b762 commit 6d0251c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Sources/utiluti/FileCommands.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// File.swift
3+
// utiluti
4+
//
5+
// Created by Armin on 25/03/2025.
6+
//
7+
8+
import Foundation

Sources/utiluti/GetUTI.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ struct GetUTI: ParsableCommand {
1414
static let configuration
1515
= CommandConfiguration(abstract: "Get the type identifier (UTI) for a file extension")
1616

17-
@Argument(help: "file extension") var fileExtension: String
17+
@Argument(help: "file extension")
18+
var fileExtension: String
19+
20+
@Flag(help: "show dynamic identifiers")
21+
var showDynamic = false
1822

1923
func run() {
2024
guard let utype = UTType(filenameExtension: fileExtension) else {
2125
Self.exit(withError: ExitCode(3))
2226
}
2327

2428
if utype.identifier.hasPrefix("dyn.") {
25-
print("<unknown extension>")
26-
Self.exit(withError: ExitCode(1))
29+
if showDynamic {
30+
print(utype.identifier)
31+
}
32+
} else {
33+
print(utype.identifier)
2734
}
28-
29-
print(utype.identifier)
3035
}
3136
}

0 commit comments

Comments
 (0)