-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting to move into a more formal structure
- Loading branch information
Showing
13 changed files
with
294 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
import Foundation | ||
|
||
struct Middleware { | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// extensions.swift | ||
// task | ||
// | ||
// Created by Wesley Cope on 11/28/16. | ||
// | ||
// | ||
|
||
import Foundation | ||
import SwiftCLI | ||
|
||
extension Equatable where Self : Command {} | ||
|
||
public func ==(lhs:Command, rhs:Command) -> Bool { | ||
return lhs.name.lowercased() == rhs.name.lowercased() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// init.swift | ||
// Task | ||
// | ||
// Created by Wesley Cope on 11/28/16. | ||
// | ||
// | ||
|
||
import Foundation | ||
import SwiftCLI | ||
import PathKit | ||
import Rainbow | ||
|
||
public class InitCommand : Command { | ||
public let name = "init" | ||
public let signature = "" | ||
public let shortDescription = "Creates an initial Taskfile in the current directory" | ||
|
||
private var today:String { | ||
let formatter = DateFormatter() | ||
formatter.dateFormat = "MM/dd/YY" | ||
|
||
return formatter.string(from: Date()) | ||
} | ||
|
||
|
||
private let template = ["// Created: {DATE}", | ||
"", | ||
"import task", | ||
"", | ||
"task(\"hello\") { arguments in", | ||
"", | ||
" print(\"world\")", | ||
"", | ||
"}", | ||
"\n",] | ||
|
||
public func execute(arguments: CommandArguments) throws { | ||
let path = Path.current + Path("Taskfile") | ||
let taskfile = template.joined(separator: "\n").replacingOccurrences(of: "{DATE}", with: today) | ||
|
||
guard let data = taskfile.data(using: .utf8) else { | ||
fatalError("Unable to write initial Taskfile") | ||
} | ||
|
||
try path.write(data) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// setup.swift | ||
// Task | ||
// | ||
// Created by Wesley Cope on 11/28/16. | ||
// | ||
// | ||
|
||
import Foundation | ||
import SwiftCLI | ||
import PathKit | ||
import Rainbow | ||
|
||
public class InitCommand : Command { | ||
public let name = "setup" | ||
public let signature = "" | ||
public let shortDescription = "Initial setup or update for Task" | ||
|
||
public func execute(arguments: CommandArguments) throws { | ||
let path = Path.current + Path("Taskfile") | ||
let taskfile = template.joined(separator: "\n").replacingOccurrences(of: "{DATE}", with: today) | ||
|
||
guard let data = taskfile.data(using: .utf8) else { | ||
fatalError("Unable to write initial Taskfile") | ||
} | ||
|
||
try path.write(data) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// version.swift | ||
// task | ||
// | ||
// Created by Wesley Cope on 11/28/16. | ||
// | ||
// | ||
|
||
import Foundation | ||
import SwiftCLI | ||
import Rainbow | ||
|
||
public class VersionCommand : Command { | ||
public let name = "version" | ||
public let signature = "" | ||
public let shortDescription = "Prints the current version of " + Task.name.bold | ||
|
||
public func execute(arguments: CommandArguments) throws { | ||
print(Task.name.green.bold + " Version: " + Task.version.bold) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// main.swift | ||
// task | ||
// | ||
// Created by Wesley Cope on 11/28/16. | ||
// | ||
// | ||
|
||
Task().run() | ||
|
||
|
File renamed without changes.
Oops, something went wrong.