Skip to content

Commit

Permalink
bum: v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
eduhds committed Feb 8, 2025
1 parent 017ce40 commit 8de9704
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Sources/JsonScripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import ArgumentParser
import Figlet
import Foundation

let VERSION = "0.0.8"
let VERSION = "0.0.9"

struct KeyValueOption: ExpressibleByArgument {
let key: String
let value: String

init?(argument: String) {
let components = argument.split(separator: "=", maxSplits: 1).map(String.init)
guard components.count == 2 else { return nil }
self.key = components[0]
self.value = components[1]
}
let key: String
let value: String

init?(argument: String) {
let components = argument.split(separator: "=", maxSplits: 1).map(String.init)
guard components.count == 2 else { return nil }
self.key = components[0]
self.value = components[1]
}
}

@main
Expand All @@ -35,8 +35,10 @@ struct JsonScripts: ParsableCommand {

@Argument(help: "Command arguments")
public var arguments: [String] = []

@Option(name: .customLong("var", withSingleDash: true), parsing: .upToNextOption, help: "Specify multiple key-value pairs in the format 'key=value'.")

@Option(
name: .customLong("var", withSingleDash: true), parsing: .upToNextOption,
help: "Specify multiple key-value pairs in the format 'key=value'.")
var variables: [KeyValueOption] = []

public func run() throws {
Expand Down Expand Up @@ -86,7 +88,7 @@ struct JsonScripts: ParsableCommand {
}
default:
var vars: [String: String] = [:]

for variable in variables {
vars[variable.key] = variable.value
}
Expand Down

0 comments on commit 8de9704

Please sign in to comment.