Skip to content

Commit

Permalink
Add version flag to executables (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboemer authored Jan 7, 2025
1 parent fa9f5e2 commit 25108c4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
29 changes: 29 additions & 0 deletions Sources/HomomorphicEncryption/Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2025 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package enum Version {
case development(branch: String)
case release(major: Int, minor: Int, patch: Int)

package static let current = Version.development(branch: "main")

package var description: String {
switch self {
case let .development(branch):
"\(branch)-development"
case let .release(major, minor, patch):
"\(major).\(minor).\(patch)"
}
}
}
4 changes: 2 additions & 2 deletions Sources/PIRGenerateDatabase/GenerateDatabase.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,7 +60,7 @@ extension [UInt8] {
@main
struct GenerateDatabaseCommand: ParsableCommand {
static let configuration: CommandConfiguration = .init(
commandName: "PIRGenerateDatabase")
commandName: "PIRGenerateDatabase", version: Version.current.description)

@Option(help: "Path to output database. Must end in '.txtpb' or '.binpb'")
var outputDatabase: String
Expand Down
4 changes: 2 additions & 2 deletions Sources/PIRProcessDatabase/ProcessDatabase.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -296,7 +296,7 @@ struct ResolvedArguments: CustomStringConvertible, Encodable {
@main
struct ProcessDatabase: AsyncParsableCommand {
static let configuration: CommandConfiguration = .init(
commandName: "PIRProcessDatabase")
commandName: "PIRProcessDatabase", version: Version.current.description)

static let logger = Logger(label: "PIRProcessDatabase")

Expand Down
5 changes: 3 additions & 2 deletions Sources/PIRShardDatabase/ShardDatabase.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
// limitations under the License.

import ArgumentParser
import HomomorphicEncryption
import PrivateInformationRetrieval
import PrivateInformationRetrievalProtobuf

Expand Down Expand Up @@ -85,7 +86,7 @@ let discussion =
@main
struct ProcessCommand: ParsableCommand {
static let configuration: CommandConfiguration = .init(
commandName: "PIRShardDatabase", discussion: discussion)
commandName: "PIRShardDatabase", discussion: discussion, version: Version.current.description)

@Option(help: "path to input PIR database file. Must have extension '.txtpb' or '.binpb'")
var inputDatabase: String
Expand Down
4 changes: 2 additions & 2 deletions Sources/PNNSGenerateDatabase/GenerateDatabase.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@ enum VectorTypeArguments: String, CaseIterable, ExpressibleByArgument {
@main
struct GenerateDatabaseCommand: ParsableCommand {
static let configuration: CommandConfiguration = .init(
commandName: "PNNSGenerateDatabase")
commandName: "PNNSGenerateDatabase", version: Version.current.description)

@Option(help: "Path to output database. Must end in '.txtpb' or '.binpb'.")
var outputDatabase: String
Expand Down
4 changes: 2 additions & 2 deletions Sources/PNNSProcessDatabase/ProcessDatabase.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -199,7 +199,7 @@ struct ResolvedArguments: CustomStringConvertible, Encodable {
@main
struct ProcessDatabase: ParsableCommand {
static let configuration: CommandConfiguration = .init(
commandName: "PNNSProcessDatabase")
commandName: "PNNSProcessDatabase", version: Version.current.description)

static let logger = Logger(label: "PNNSProcessDatabase")

Expand Down

0 comments on commit 25108c4

Please sign in to comment.