summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-10-02 02:14:42 +0200
committerNikolaus Gotsche <n@softwarefools.com>2018-10-02 02:14:42 +0200
commita4a53949409944ae1745a8ab16901fb9a21ac7c4 (patch)
tree8a7840c1e6f1146961c76914abf9ec3613a2750c
parentba96c6fae2ca3ea3399934ffd010cecfbaec273c (diff)
new IsSure
-rw-r--r--config.go2
-rw-r--r--interact.go12
-rw-r--r--sqlite.go4
3 files changed, 15 insertions, 3 deletions
diff --git a/config.go b/config.go
index 851c93b..50ee7db 100644
--- a/config.go
+++ b/config.go
@@ -46,7 +46,7 @@ func editConf() {
makeNewTOML(false)
}else{
showConfig()
- if isSure("Is this Configuration Correct?") {
+ if isInterSure("Is this Configuration Correct?") {
break
}else{
//if isSure("Enter new Configuration?"){
diff --git a/interact.go b/interact.go
index 932ce1d..906d221 100644
--- a/interact.go
+++ b/interact.go
@@ -644,7 +644,19 @@ func interact() {
//fmt.Println("Laboravi emeritus...")
}
+func isInterSure(question string) (bool) {
+ shell := ishell.New()
+ shell.ShowPrompt(false)
+ defer shell.ShowPrompt(true)
+ shell.Printf("%s (type 'y/Y/yes' to confirm) : ",question)
+ line := shell.ReadLine()
+ if ( line == "yes" || line == "y" || line == "Y") {
+ return true
+ } else {
+ return false
+ }
+}
func getInterInput(question string) (out string) {
shell := ishell.New()
diff --git a/sqlite.go b/sqlite.go
index c090c0a..1907ddd 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -978,7 +978,7 @@ func deleteBill(id int) {
hsum := sumFloatArray(string2FloatArray(hours,";"))
msum := sumFloatArray(string2FloatArray(moneys,";"))
fmt.Printf("%v: For %v- %v (%v) - %.1f[h] : %.2f[€]\n",identity,custr,prstr,date.Local().Format("2006 Mon Jan _2"),hsum,msum)
- if isSure("Are You Sure?") {
+ if isInterSure("Are You Sure?") {
uncheckTasks(id) //Set corresponding Tasks to checkout=0
stmt, err := db.Prepare("DELETE FROM bills WHERE id = ?")
checkErr(err)
@@ -1010,7 +1010,7 @@ func deleteTask(id int) {
//fmt.Println(boldGreen("Delete Task", id))
dur := float64(stop.Sub(start))/(1000000000*60*60)
fmt.Printf("%v: %v (%v-%v) - %.2f h\n",prj,task,start.Local().Format("2006 Mon Jan _2 15:04"),stop.Local().Format("15:04"),dur)
- if isSure("Are You Sure?") {
+ if isInterSure("Are You Sure?") {
stmt, err := db.Prepare("DELETE FROM timetable WHERE id = ?")
checkErr(err)
_, err = stmt.Exec(id)