mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-27 20:36:29 -04:00
Implement offline shearing/removal
This commit is contained in:
@@ -33,7 +33,8 @@ func main() {
|
||||
switch args[2] {
|
||||
case "show", "-s":
|
||||
cli.EntryReaderShortcut(targetLocation, false)
|
||||
case "shear": // TODO offline.Shear(targetLocation), exit after run
|
||||
case "shear":
|
||||
offline.Shear(targetLocation)
|
||||
case "gen": // TODO offline.Gen(targetLocation), exit after run
|
||||
case "copy":
|
||||
cli.HelpCopy()
|
||||
|
||||
+1
-1
@@ -9,7 +9,6 @@ func AddFolder(targetLocation string) {
|
||||
// create the directory specified by targetLocation
|
||||
err := os.Mkdir(targetLocation, 0700)
|
||||
if err != nil {
|
||||
// if the directory already exists, print an error message and exit
|
||||
if os.IsExist(err) {
|
||||
fmt.Println(AnsiError + "Directory already exists" + AnsiReset)
|
||||
os.Exit(1)
|
||||
@@ -19,4 +18,5 @@ func AddFolder(targetLocation string) {
|
||||
}
|
||||
}
|
||||
// TODO If in online mode, create the directory on the server
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package offline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Shear(targetLocation string) {
|
||||
// TODO If in online mode, remove from server and add to shear list
|
||||
TargetIsFile(targetLocation, true, 0) // needed because os.RemoveAll does not return an error if target does not exist
|
||||
err := os.RemoveAll(targetLocation)
|
||||
if err != nil {
|
||||
fmt.Println(AnsiError + "Failed to remove target: " + err.Error() + AnsiReset)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
Reference in New Issue
Block a user