68 lines
1.8 KiB
Swift
68 lines
1.8 KiB
Swift
//
|
|
// Analytics.swift
|
|
//
|
|
//
|
|
// Created by Loris Perret on 08/12/2023.
|
|
//
|
|
|
|
import ToolCore
|
|
import Foundation
|
|
import ArgumentParser
|
|
|
|
struct Analytics: ParsableCommand {
|
|
|
|
// MARK: - Command Configuration
|
|
|
|
static var configuration = CommandConfiguration(
|
|
abstract: "Generate analytics extension file.",
|
|
version: ResgenSwiftVersion
|
|
)
|
|
|
|
|
|
// MARK: - Static
|
|
|
|
static let toolName = "Analytics"
|
|
static let defaultExtensionName = "Analytics"
|
|
|
|
// MARK: - Command Options
|
|
|
|
@OptionGroup var options: AnalyticsOptions
|
|
|
|
// MARK: - Run
|
|
|
|
mutating func run() {
|
|
print("[\(Self.toolName)] Starting analytics generation")
|
|
print("[\(Self.toolName)] Will use inputFile \(options.inputFile) to generate analytics for target: \(options.target)")
|
|
print("[\(Self.toolName)] Will generate analytics")
|
|
|
|
// Parse input file
|
|
let sections = AnalyticsFileParser.parse(options.inputFile, target: options.target)
|
|
|
|
// Generate extension
|
|
AnalyticsGenerator.writeExtensionFiles(sections: sections,
|
|
target: options.target,
|
|
tags: ["ios", "iosonly"],
|
|
staticVar: options.staticMembers,
|
|
extensionName: options.extensionName,
|
|
extensionFilePath: options.extensionFilePath)
|
|
|
|
print("[\(Self.toolName)] Analytics generated")
|
|
}
|
|
}
|
|
|
|
extension Analytics {
|
|
enum TargetType: CaseIterable {
|
|
case matomo
|
|
case firebase
|
|
|
|
var value: String {
|
|
switch self {
|
|
case .matomo:
|
|
"matomo"
|
|
case .firebase:
|
|
"firebase"
|
|
}
|
|
}
|
|
}
|
|
}
|