mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Implement ability to add folders/directories (offline)
This commit is contained in:
@@ -51,7 +51,7 @@ func main() {
|
|||||||
|
|
||||||
switch args[2] {
|
switch args[2] {
|
||||||
case "copy":
|
case "copy":
|
||||||
var field int
|
var field int // indicates which (numbered) field to copy
|
||||||
switch args[3] {
|
switch args[3] {
|
||||||
case "password", "-p":
|
case "password", "-p":
|
||||||
field = 0
|
field = 0
|
||||||
@@ -83,14 +83,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
// TODO offline.EditEntry(targetLocation, field), exit after run
|
// TODO offline.EditEntry(targetLocation, field), exit after run
|
||||||
case "add":
|
case "add":
|
||||||
var field rune
|
var field bool // indicates whether to add a password or note
|
||||||
field = field // TODO temporary to avoid unused variable error
|
field = field // TODO temporary to avoid unused variable error
|
||||||
switch args[3] {
|
switch args[3] {
|
||||||
case "password", "-p":
|
case "password", "-p":
|
||||||
field = 'p'
|
field = true
|
||||||
case "note", "-n":
|
case "note", "-n":
|
||||||
field = 'n'
|
field = false
|
||||||
case "folder", "-f": // TODO offline.AddFolder(targetLocation), exit after run
|
case "folder", "-f":
|
||||||
|
offline.AddFolder(targetLocation)
|
||||||
default:
|
default:
|
||||||
cli.HelpAdd()
|
cli.HelpAdd()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package offline
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
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)
|
||||||
|
} else {
|
||||||
|
fmt.Println(AnsiError + "Failed to create directory: " + err.Error() + AnsiReset)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO If in online mode, create the directory on the server
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user