Skip to content

Commit ea88984

Browse files
committed
Add command to print current version number
Closes #45
1 parent 4744dd8 commit ea88984

File tree

8 files changed

+41
-35
lines changed

8 files changed

+41
-35
lines changed

Package.resolved

Lines changed: 12 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ let package = Package(
1212
.executable(name: "figma-export", targets: ["FigmaExport"])
1313
],
1414
dependencies: [
15-
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.0.1"),
16-
.package(url: "https://github.com/jpsim/Yams.git", from: "3.0.0"),
17-
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
15+
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.3.0"),
16+
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.0"),
17+
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
1818
.package(url: "https://github.com/stencilproject/Stencil.git", from: "0.14.0"),
1919
.package(url: "https://github.com/tuist/XcodeProj.git", from: "7.14.0")
2020
],

Sources/FigmaExport/Subcommands/ExportColors.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ extension FigmaExportCommand {
1515
abstract: "Exports colors from Figma",
1616
discussion: "Exports light and dark color palette from Figma to Xcode / Android Studio project")
1717

18-
@Option(name: .shortAndLong, default: "figma-export.yaml", help: "An input YAML file with figma and platform properties.")
19-
var input: String
18+
@Option(name: .shortAndLong, help: "An input YAML file with figma and platform properties.")
19+
var input: String = "figma-export.yaml"
2020

2121
func run() throws {
2222
let logger = Logger(label: "com.redmadrobot.figma-export")

Sources/FigmaExport/Subcommands/ExportIcons.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ extension FigmaExportCommand {
1515
abstract: "Exports icons from Figma",
1616
discussion: "Exports icons from Figma to Xcode / Android Studio project")
1717

18-
@Option(name: .shortAndLong, default: "figma-export.yaml",
19-
help: "An input YAML file with figma and platform properties.")
20-
var input: String
18+
@Option(name: .shortAndLong, help: "An input YAML file with figma and platform properties.")
19+
var input: String = "figma-export.yaml"
2120

2221
@Argument(help: """
2322
[Optional] Name of the icons to export. For example \"ic/24/edit\" \

Sources/FigmaExport/Subcommands/ExportImages.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ extension FigmaExportCommand {
1515
abstract: "Exports images from Figma",
1616
discussion: "Exports images from Figma to Xcode / Android Studio project")
1717

18-
@Option(name: .shortAndLong, default: "figma-export.yaml",
19-
help: "An input YAML file with figma and platform properties.")
20-
var input: String
18+
@Option(name: .shortAndLong, help: "An input YAML file with figma and platform properties.")
19+
var input: String = "figma-export.yaml"
2120

2221
@Argument(help: """
2322
[Optional] Name of the images to export. For example \"img/login\" to export \

Sources/FigmaExport/Subcommands/ExportTypography.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ extension FigmaExportCommand {
1515
abstract: "Exports typography from Figma",
1616
discussion: "Exports font styles from Figma to Xcode")
1717

18-
@Option(name: .shortAndLong, default: "figma-export.yaml", help: "An input YAML file with figma and platform properties.")
19-
var input: String
18+
@Option(name: .shortAndLong, help: "An input YAML file with figma and platform properties.")
19+
var input: String = "figma-export.yaml"
2020

2121
func run() throws {
2222
let logger = Logger(label: "com.redmadrobot.figma-export")
@@ -35,7 +35,7 @@ extension FigmaExportCommand {
3535
let loader = TextStylesLoader(figmaClient: client, params: params.figma)
3636
let textStyles = try loader.load()
3737

38-
if let ios = params.ios {//
38+
if let ios = params.ios {
3939
logger.info("Saving text styles...")
4040
try exportXcodeTextStyles(textStyles: textStyles, iosParams: ios, logger: logger)
4141
logger.info("Done!")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import ArgumentParser
2+
3+
/// Encapsulates `--version` flag behavior.
4+
struct VersionOptions: ParsableArguments {
5+
@Flag(name: .shortAndLong, help: "Print the version and exit")
6+
var version: Bool = false
7+
8+
func validate() throws {
9+
if version {
10+
print("0.18.2")
11+
throw ExitCode.success
12+
}
13+
}
14+
}

Sources/FigmaExport/main.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct FigmaExportCommand: ParsableCommand {
4545
defaultSubcommand: ExportColors.self
4646
)
4747

48+
@OptionGroup()
49+
var versionOptions: VersionOptions
50+
4851
}
4952

5053
FigmaExportCommand.main()

0 commit comments

Comments
 (0)