summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlshprung <lshprung@yahoo.com>2020-10-12 22:20:55 -0700
committerlshprung <lshprung@yahoo.com>2020-10-12 22:20:55 -0700
commit4313a39544cde16e5750f5affc1b7702770c1699 (patch)
tree71e0ea2862f0daad8c40fbce0869c6f5699a9cff
parentd529fcc336110d243beeef3d393c1122a8238a39 (diff)
Improved error messages and readme
-rw-r--r--docs/README.md7
-rw-r--r--docs/screenshot1.pngbin0 -> 28376 bytes
-rw-r--r--docs/screenshot2.pngbin0 -> 33241 bytes
-rw-r--r--docs/tml-config.5.gzbin2153 -> 2150 bytes
-rw-r--r--docs/tml-config.md4
-rw-r--r--draw.c6
-rw-r--r--group.c4
-rw-r--r--read_cfg.c18
-rw-r--r--read_cfg.h2
9 files changed, 35 insertions, 6 deletions
diff --git a/docs/README.md b/docs/README.md
index 9a7db57..db5da29 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -4,7 +4,7 @@
## Compiling and Running
-tml can be compiled on any system with gcc and the ncurses library installed. It has been tested to work on Ubuntu, and can also be compiled and run on Windows 10, but is designed with Linux in mind. To compile and run tml:
+tml can be compiled on any system with make, gcc, and the ncurses library (libncurses-dev) installed. It has been tested to work on Ubuntu, and can also be compiled and run on Windows 10, but is designed with Linux in mind. To compile and run tml:
1. Clone the repository
2. Run `make` in the directory the repository was cloned into. This will create a file called `tml`
@@ -27,6 +27,11 @@ To uninstall these files:
sudo make uninstall
```
+## Screenshots
+
+![screenshot 1](screenshot1.png)
+![screenshot 2](screenshot2.png)
+
## Configuration File
By default, tml searches in the following order for a configuration file:
diff --git a/docs/screenshot1.png b/docs/screenshot1.png
new file mode 100644
index 0000000..7c11b94
--- /dev/null
+++ b/docs/screenshot1.png
Binary files differ
diff --git a/docs/screenshot2.png b/docs/screenshot2.png
new file mode 100644
index 0000000..903304b
--- /dev/null
+++ b/docs/screenshot2.png
Binary files differ
diff --git a/docs/tml-config.5.gz b/docs/tml-config.5.gz
index 8f06624..429dd3d 100644
--- a/docs/tml-config.5.gz
+++ b/docs/tml-config.5.gz
Binary files differ
diff --git a/docs/tml-config.md b/docs/tml-config.md
index 63f3cfb..b02ee21 100644
--- a/docs/tml-config.md
+++ b/docs/tml-config.md
@@ -126,7 +126,7 @@ autoAlias on
# Adding a Group of Various Applications
-addGroup Applcations
+addGroup Applications
addName GIMP /usr/bin/gimp Applications
addName Chromium /usr/bin/chromium-browser Applications
addName Thunderbird /usr/bin/thunderbird Applications
@@ -141,7 +141,7 @@ add /home/john/Videos/*mp4 Videos
addGroup Pictures
setLauncher Pictures /usr/bin/sxiv
-setFlags "-s f"
+setFlags Pictures "-s f"
add /home/john/Pictures/*jpg Pictures
add /home/john/Pictures/*png Pictures
addR "/mnt/External_Drive/Johns Photos/*" Pictures
diff --git a/draw.c b/draw.c
index ced51fb..c72eb6e 100644
--- a/draw.c
+++ b/draw.c
@@ -67,6 +67,12 @@ int main(int argc, char **argv){
g = get_groups(); //retrieve results of cfg_interp
g_count = get_gcount(g); //retrieve number of groups in g (only do this after removing empty groups)
+ //check that there are is at least one valid group
+ if(g_count == 0){
+ printf("Error: No Entries!\n");
+ exit(0);
+ }
+
initscr();
cbreak();
keypad(stdscr, true);
diff --git a/group.c b/group.c
index ca47edd..821adf3 100644
--- a/group.c
+++ b/group.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include "entry.h"
#include "group.h"
+#include "read_cfg.h"
#define BUF_LEN 1024
typedef struct group{
@@ -143,7 +144,8 @@ void clean_groups(){
GROUP *hold;
if(group_count == 0){
- printf("Error: no groups!\n");
+ printf("Error: no groups! ");
+ refer_to_doc();
exit(0);
}
diff --git a/read_cfg.c b/read_cfg.c
index 6007a91..6c37fe3 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -18,6 +18,7 @@ void cfg_interp(char *path);
int get_compmode();
bool get_sort();
bool get_case_sensitivity();
+void refer_to_doc();
//private
void check_line(char *buffer, char **options, int ln);
@@ -60,10 +61,12 @@ char *find_config(){
for(i = 0; i < check_count; i++){
path = choices[i];
+ printf("Checking for config at %s: ", choices[i]);
if(access(path, R_OK) == 0){
- printf("Using config \"%s\"\n", path);
+ printf("Using config \"%s\"\n\n", path);
return path;
}
+ else printf("File does not exist\n");
}
return "config";
@@ -80,7 +83,13 @@ void cfg_interp(char *path){
int j;
fp = fopen(path, "r");
- assert(fp != NULL);
+ //assert(fp != NULL);
+ if(fp == NULL){
+ printf("config does not exist in current directory. ");
+ refer_to_doc();
+ exit(0);
+ }
+ else if(!strcmp(path, "config")) printf("Using config in current directory\n");
//build the options array
char **options = malloc(sizeof(char *) * OPTION_CNT);
@@ -134,6 +143,11 @@ bool get_case_sensitivity(){
return fold_case;
}
+void refer_to_doc(){
+ printf("Refer to documentation on how to create tml config file\n");
+ return;
+}
+
//TODO add support for "addR" recursive adding (still needs work...)
//TODO add support for "alias" option
//TODO add support for "hide" option
diff --git a/read_cfg.h b/read_cfg.h
index 20aebe4..e6583de 100644
--- a/read_cfg.h
+++ b/read_cfg.h
@@ -9,4 +9,6 @@ bool get_sort();
bool get_case_sensitivity();
+void refer_to_doc();
+
#endif