Rename commands

This commit is contained in:
Simon Kågedal Reimer 2019-06-15 14:09:51 +02:00
parent 88feaec305
commit 62edec831f
12 changed files with 28 additions and 28 deletions

View File

@ -2,18 +2,18 @@
[![Swift 5 compatible][swift-badge]][Swift] [![Xcode 10.2 compatible][xcode-badge]][Xcode] [![Swift 5 compatible][swift-badge]][Swift] [![Xcode 10.2 compatible][xcode-badge]][Xcode]
This is a tool to manage Xcode simulators and their [root certificates][RootCertificate]. This is a tool to manage [root certificates][RootCertificate] in Xcode simulators.
If you have a certificate for your server in PEM format in a file `myhost.crt`, type: If you have a certificate for your server in PEM format in a file `myhost.crt`, type:
```bash ```bash
$ xcode-simulator-cert install-ca myhost.crt $ xcode-simulator-cert install myhost.crt
``` ```
It will then install the certificate in all your simulators. You can also specify a specific simulator: It will then install the certificate in all your simulators. You can also specify a specific simulator:
```bash ```bash
$ xcode-simulator-cert install-ca myhost.crt --device-name="iPhone 8" $ xcode-simulator-cert install myhost.crt --device-name="iPhone 8"
``` ```
There are also some other subcommands and options available. `--help` is your friend. There are also some other subcommands and options available. `--help` is your friend.

View File

@ -33,10 +33,10 @@ struct CommandLineOptions {
fileprivate(set) var verbosity: Verbosity fileprivate(set) var verbosity: Verbosity
private static let allCommands: [Command] = [ private static let allCommands: [Command] = [
ListDevicesCommand(), ListCommand(),
InstallCACommand(), InstallCommand(),
ExportCACommand(), ExportCommand(),
RemoveCACommand() RemoveCommand()
] ]
static func parse(commandName: String, arguments: [String]) throws -> CommandLineOptions { static func parse(commandName: String, arguments: [String]) throws -> CommandLineOptions {

View File

@ -6,10 +6,10 @@ import Foundation
import Basic import Basic
import SPMUtility import SPMUtility
class ExportCACommand: Command { class ExportCommand: Command {
private struct Options { private struct Options {
} }
let name = "export-ca" let name = "export"
let overview = "Export Certificate Authorities" let overview = "Export Certificate Authorities"
private let binder = ArgumentBinder<Options>() private let binder = ArgumentBinder<Options>()

View File

@ -5,12 +5,12 @@
import Foundation import Foundation
import SPMUtility import SPMUtility
class InstallCACommand: Command { class InstallCommand: Command {
struct Options { struct Options {
var path: String? var path: String?
var dryRun: Bool = false var dryRun: Bool = false
} }
let name = "install-ca" let name = "install"
let overview = "Install a Certificate Authority" let overview = "Install a Certificate Authority"
private let binder = ArgumentBinder<Options>() private let binder = ArgumentBinder<Options>()
@ -45,7 +45,7 @@ class InstallCACommand: Command {
} }
func run(reporter: Reporter) throws { func run(reporter: Reporter) throws {
let runner = InstallCACommandRunner( let runner = InstallCommandRunner(
options: options, options: options,
filteringOptions: filteringOptions, filteringOptions: filteringOptions,
reporter: reporter reporter: reporter

View File

@ -4,13 +4,13 @@
import Foundation import Foundation
class InstallCACommandRunner { class InstallCommandRunner {
private let reporter: Reporter private let reporter: Reporter
private let options: InstallCACommand.Options private let options: InstallCommand.Options
private let filteringOptions: FilteringOptions private let filteringOptions: FilteringOptions
init( init(
options: InstallCACommand.Options, options: InstallCommand.Options,
filteringOptions: FilteringOptions, filteringOptions: FilteringOptions,
reporter: Reporter) { reporter: Reporter) {
self.reporter = reporter self.reporter = reporter

View File

@ -5,11 +5,11 @@
import Foundation import Foundation
import SPMUtility import SPMUtility
class ListDevicesCommand: Command { class ListCommand: Command {
let name = "list-devices" let name = "list"
let overview = "List available Xcode Simulator devices" let overview = "List available certificates in Xcode Simulators"
private let binder = ArgumentBinder<ListDevicesCommand>() private let binder = ArgumentBinder<ListCommand>()
private var filteringOptions = FilteringOptions() private var filteringOptions = FilteringOptions()
private let filteringBinder = ArgumentBinder<FilteringOptions>() private let filteringBinder = ArgumentBinder<FilteringOptions>()

View File

@ -5,11 +5,11 @@
import Foundation import Foundation
import SPMUtility import SPMUtility
class RemoveCACommand: Command { class RemoveCommand: Command {
private struct Options { private struct Options {
var dryRun: Bool = false var dryRun: Bool = false
} }
let name = "remove-ca" let name = "remove"
let overview = "Remove all Certificate Authorities from specified devices" let overview = "Remove all Certificate Authorities from specified devices"
private let binder = ArgumentBinder<Options>() private let binder = ArgumentBinder<Options>()

View File

@ -3,7 +3,7 @@
// Should not be under version control. // Should not be under version control.
// //
public extension XcodeSimulatorTool { public extension XcodeSimulatorCert {
static var version: String { static var version: String {
return "0.1.0" return "0.1.0"
} }

View File

@ -6,7 +6,7 @@ import Foundation
import Basic import Basic
import SPMUtility import SPMUtility
public class XcodeSimulatorTool { public class XcodeSimulatorCert {
private let arguments: [String] private let arguments: [String]
public init(arguments: [String]) { public init(arguments: [String]) {
@ -39,7 +39,7 @@ public class XcodeSimulatorTool {
case .noCommand: case .noCommand:
options.printUsage(on: stdoutStream) options.printUsage(on: stdoutStream)
case .version: case .version:
print("xcode-simulator-cert version \(XcodeSimulatorTool.version)") print("xcode-simulator-cert version \(XcodeSimulatorCert.version)")
case .command(let command): case .command(let command):
try command.run(reporter: DefaultReporter(verbosity: options.verbosity)) try command.run(reporter: DefaultReporter(verbosity: options.verbosity))
} }

View File

@ -5,4 +5,4 @@
import Foundation import Foundation
import XcodeSimulatorKit import XcodeSimulatorKit
exit(XcodeSimulatorTool(arguments: CommandLine.arguments).run()) exit(XcodeSimulatorCert(arguments: CommandLine.arguments).run())

View File

@ -39,8 +39,8 @@ fi
echo "${LOGO} Installing root certificate" echo "${LOGO} Installing root certificate"
pushd .. >& /dev/null pushd .. >& /dev/null
echo swift run xcode-simulator-cert --verbosity=loud install-ca ${CERT_PATH} --uuid=${UUID} echo swift run xcode-simulator-cert --verbosity=loud install ${CERT_PATH} --uuid=${UUID}
swift run xcode-simulator-cert --verbosity=loud install-ca ${CERT_PATH} --uuid=${UUID} swift run xcode-simulator-cert --verbosity=loud install ${CERT_PATH} --uuid=${UUID}
popd >& /dev/null popd >& /dev/null
# Booting # Booting

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# This can be useful for testing the install-ca command # This can be useful for testing the install command
openssl req -x509 -newkey rsa:4096 -keyout test-ca.key -out test-ca.crt -days 365 -nodes -subj '/CN=localhost' openssl req -x509 -newkey rsa:4096 -keyout test-ca.key -out test-ca.crt -days 365 -nodes -subj '/CN=localhost'