Skip to content

Commit

Permalink
Added current version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
calebkleveter committed Jul 31, 2017
1 parent 6938986 commit 8c5e9de
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
45 changes: 45 additions & 0 deletions Sources/Ether/Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Caleb Kleveter
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Console

public final class Version: Command {
public let id = "update"

public let signature: [Argument] = []

public let help: [String] = [
"Outputs the current version of Ether."
]

public let console: ConsoleProtocol
public let version: String

public init(console: ConsoleProtocol, version: String) {
self.console = console
self.version = version
}

public func run(arguments: [String]) throws {
console.output("Ether Version: \(version)", style: .info, newLine: true)
}
}
10 changes: 8 additions & 2 deletions Sources/Executable/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ import Console
import Ether
import libc

// The current version of Ether. This string should be updated with each release.
let version = "1.5"
var arguments = CommandLine.arguments

let terminal = Terminal(arguments: arguments)
if arguments.contains("--version") {
arguments.insert("version", at: 1)
}

let terminal = Terminal(arguments: arguments)
var iterator = arguments.makeIterator()

guard let executable = iterator.next() else {
Expand All @@ -44,7 +49,8 @@ do {
New(console: terminal),
Group(id: "version", commands: [
VersionLatest(console: terminal)
], help: ["For interacting with dependency versions"])
], help: ["For interacting with dependency versions"]),
Version(console: terminal, version: version)
], arguments: Array(iterator),
help: [
"MIT 2017 Caleb Kleveter.",
Expand Down

0 comments on commit 8c5e9de

Please sign in to comment.