aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/c_go2work.go9
-rw-r--r--src/u_checks.go4
-rw-r--r--src/u_prints.go15
-rw-r--r--src/u_utils.go4
4 files changed, 26 insertions, 6 deletions
diff --git a/src/c_go2work.go b/src/c_go2work.go
index f919d1b..e11dab4 100644
--- a/src/c_go2work.go
+++ b/src/c_go2work.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* go2work: src/c_go2work.go
- * Mon Apr 4 17:06:21 CEST 2022
+ * Mon Apr 4 17:25:53 CEST 2022
* Joe
*
* The main.
@@ -50,9 +50,9 @@ package main
import (
"log"
"os"
- "time"
"strconv"
"strings"
+ "time"
)
func main() {
@@ -103,6 +103,11 @@ func main() {
}
curr_t = get_time()
print_time_left(curr_t, dest_t)
+ main_loop(dest_t, options)
+}
+
+func main_loop(dest_t [3]byte, options Options) {
+ var curr_t [3]byte
ticker := time.NewTicker(INTERVAL * time.Millisecond)
quit := make(chan struct{})
for {
diff --git a/src/u_checks.go b/src/u_checks.go
index 6188803..9a12608 100644
--- a/src/u_checks.go
+++ b/src/u_checks.go
@@ -48,6 +48,7 @@
package main
import (
+ "fmt"
"os"
"os/exec"
)
@@ -81,6 +82,9 @@ func check_time_format(time [3]byte) bool {
}
func check_file_exists(file string) bool {
+ if file == "" {
+ fmt.Println("empty")
+ }
_, err := os.Stat(file)
if os.IsNotExist(err) == true {
return false
diff --git a/src/u_prints.go b/src/u_prints.go
index 205f04b..e6cea26 100644
--- a/src/u_prints.go
+++ b/src/u_prints.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* go2work: src/u_prints.go
- * Fri Apr 1 18:49:41 CEST 2022
+ * Mon Apr 4 17:25:43 CEST 2022
* Joe
*
* Stuff to print
@@ -49,6 +49,7 @@ package main
import (
"fmt"
+ "log"
)
func print_time(t [3]byte) {
@@ -110,12 +111,18 @@ func print_version() {
}
func print_fortune_not_found() {
- fmt.Println("Beware, fortune is set on but was not found")
+ fmt.Print("\n\n")
+ log.Println("beware, fortune is set on but was not found")
}
+func print_no_files() {
+ fmt.Print("\n\n")
+ log.Println("beware, no files selected! Using default ringtone")
+}
func print_file_not_found(file string) {
- fmt.Println("\n\nBeware, file \"" +
+ fmt.Print("\n\n")
+ log.Println("beware, file '" +
file +
- "\" not found! Using default ringtone",
+ "' not found! Using default ringtone",
)
}
diff --git a/src/u_utils.go b/src/u_utils.go
index b93832c..b523f7f 100644
--- a/src/u_utils.go
+++ b/src/u_utils.go
@@ -89,6 +89,10 @@ func get_test_time() [3]byte {
func choose_file(options Options) int {
file_id := len(options.Files)
+ if file_id == 0 {
+ print_no_files()
+ return -1
+ }
if options.Random == true && file_id > 1 {
rand.Seed(time.Now().UnixNano())
file_id = rand.Intn(file_id)