aboutsummaryrefslogtreecommitdiff
path: root/src/dir_monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dir_monitor.c')
-rw-r--r--src/dir_monitor.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/dir_monitor.c b/src/dir_monitor.c
index 46409cd..935aa74 100644
--- a/src/dir_monitor.c
+++ b/src/dir_monitor.c
@@ -19,17 +19,26 @@ int main(int argc, char **argv) {
struct list_head *list = NULL;
int path_index = 1;
- if (argc < 2) {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- path_index = parse_arguments(argc, argv);
- if (path_index == argc) {
- usage(argv[0]);
- return EXIT_FAILURE;
+ if (argc > 2) {
+ path_index = parse_arguments(argc, argv);
+ if (path_index == argc) {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ list = get_data_from_directory(argv[path_index]);
+ } else if (argc == 2) {
+ if (argv[1][0] == '-') {
+ fputc('\n', stderr);
+ LOGERR("WARNING: if '%s' is a valid path use a prefix like ./\n\n",
+ argv[1]);
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ list = get_data_from_directory(argv[1]);
+ } else {
+ list = get_data_from_directory(".");
}
- list = get_data_from_directory(argv[path_index]);
if (option_format_string == NULL) {
print_list(list);
} else {