Skip to content

Commit

Permalink
add edit command input for copying file back
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
yonaskolb committed Jan 5, 2018
1 parent bb9d175 commit 603da55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ version 1.2.0 released

#### Edit the swift file
This generates and opens an Xcode project with all dependencies linked, which is useful for code completion if you have defined any dependencies.
The command line will prompt you to type `c` to commit any changes you made in Xcode back to the original file

```sh
$ beak edit
Expand Down
10 changes: 9 additions & 1 deletion Sources/BeakCore/Commands/EditCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ class EditCommand: BeakCommand {
// run package
try packageContext.runAndPrint(bash: "open \(options.packageName).xcodeproj")
print("Edit the file \"Sources/\(options.packageName)/main.swift\"")
print("When you're finished you will have to manually copy and paste the file back to \(path.string)")
print("When you're finished type \"c\" to commit the changes and copy the file back to \(path.string), otherwise type anything else")
let line = readLine()
if line?.lowercased() == "c" {
try path.delete()
try packageManager.mainFilePath.copy(path)
print("Copied edited file back to \(path.string)")
} else {
print("Changes not copied back to \(path.string)")
}
}
}

0 comments on commit 603da55

Please sign in to comment.