feat: Adds generate-config as json file.
This commit is contained in:
@@ -11,8 +11,14 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
|
||||
abstract: "\("Generate a local configuration file.".blue)",
|
||||
discussion: """
|
||||
|
||||
If a directory is not supplied then a configuration file will be created
|
||||
at \("'~/.config/hpa-playbook/config'".yellow).
|
||||
\("NOTE:".yellow) If a directory is not supplied then a configuration file will be created
|
||||
at \("'~/.config/hpa-playbook/config'".yellow).
|
||||
|
||||
\("Example:".yellow)
|
||||
|
||||
\("Create a directory and generate the configuration file.".green)
|
||||
$ mkdir -p ~/.config/hpa-playbook
|
||||
$ hpa generate-config --path ~/.config/hpa-playbook
|
||||
|
||||
"""
|
||||
)
|
||||
@@ -24,6 +30,12 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
|
||||
)
|
||||
var path: String?
|
||||
|
||||
@Flag(
|
||||
name: .shortAndLong,
|
||||
help: "Generate a json file, instead of default env style"
|
||||
)
|
||||
var json: Bool = false
|
||||
|
||||
@OptionGroup var globals: BasicGlobalOptions
|
||||
|
||||
mutating func run() async throws {
|
||||
@@ -48,7 +60,7 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
|
||||
actualPath = "\(path)/config"
|
||||
}
|
||||
|
||||
try cliClient.createConfiguration(actualPath)
|
||||
try cliClient.createConfiguration(actualPath, json)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ struct BasicGlobalOptions: ParsableArguments {
|
||||
|
||||
}
|
||||
|
||||
@dynamicMemberLookup
|
||||
struct GlobalOptions: ParsableArguments {
|
||||
|
||||
@Option(
|
||||
@@ -44,4 +45,9 @@ struct GlobalOptions: ParsableArguments {
|
||||
|
||||
@OptionGroup var basic: BasicGlobalOptions
|
||||
|
||||
subscript<T>(dynamicMember keyPath: WritableKeyPath<BasicGlobalOptions, T>) -> T {
|
||||
get { basic[keyPath: keyPath] }
|
||||
set { basic[keyPath: keyPath] = newValue }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user