diff --git a/Sources/specgen/CommandLineParsing/Bootstrap/RootParser.swift b/Sources/specgen/CommandLineParsing/Bootstrap/RootParser.swift index a6b3d66..e14dfa8 100644 --- a/Sources/specgen/CommandLineParsing/Bootstrap/RootParser.swift +++ b/Sources/specgen/CommandLineParsing/Bootstrap/RootParser.swift @@ -10,11 +10,13 @@ import SPMUtility class RootParser { let argumentParser: ArgumentParser + let printVersion: OptionArgument init() { argumentParser = ArgumentParser( usage: " \nRun '\(ProcessInfo.processInfo.processName) --help' for information about each subcommand", overview: "A command line tool for generating podspec files from frameworks, so they can be used in a CocoaPods setup" ) + printVersion = argumentParser.add(option: "--version", shortName: "-v", kind: Bool.self, usage: "Prints the version", completion: nil) } } diff --git a/Sources/specgen/main.swift b/Sources/specgen/main.swift index 7166819..cb02654 100644 --- a/Sources/specgen/main.swift +++ b/Sources/specgen/main.swift @@ -13,6 +13,11 @@ do { // If execution got to this point, means that the provided arguments are correct + if commandLineArguments.get(rootParser.printVersion) == true { + print(version) + exit(0) + } + switch try Command(rootParser.argumentParser, commandLineArguments) { case .bootstrap: let boostrapArgs = BootstrapArguments(commandLineArguments, parser: bootstrapSubparser)