Skip to content

Commit

Permalink
Add version command line option
Browse files Browse the repository at this point in the history
Fixes #22.
  • Loading branch information
saagarjha committed Oct 30, 2022
1 parent 2522f56 commit 4a65787
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions unxip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,13 @@ extension option {

struct Options {
static let options: [(flag: String, name: StaticString, description: StringLiteralType)] = [
("V", "version", "Print the unxip version number."),
("c", "compression-disable", "Disable APFS compression of result."),
("h", "help", "Print this help message."),
("n", "dry-run", "Dry run. (Often useful with -v.)"),
("v", "verbose", "Print xip file contents."),
]
static let version = "1.1.1"

var input: URL
var output: URL?
Expand All @@ -262,6 +264,8 @@ struct Options {
dryRun = true
case "h":
Self.printUsage(nominally: true)
case "V":
Self.printVersion()
case "v":
verbose = true
default:
Expand All @@ -285,6 +289,11 @@ struct Options {

self.output = URL(fileURLWithPath: output)
}

static func printVersion() -> Never {
print("unxip \(version)")
exit(EXIT_SUCCESS)
}

static func printUsage(nominally: Bool) -> Never {
fputs(
Expand Down

0 comments on commit 4a65787

Please sign in to comment.