commit 837d0d6fb94d9922a2d22b59e290f4df3f3e5ff0
parent 885f9e117bac816becba3a804f5dce27e123f168
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Tue, 5 Jan 2021 03:07:28 -0800
Simplify cprint()
Diffstat:
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/command.c b/command.c
@@ -102,19 +102,14 @@ cgoto(int argc, char const **argv, int ino, char const **item)
int
cprint(int argc, char const **argv, int ino, char const **item)
{
- warg(1, 2, argc, argv);
+ if (warg(1, 1, argc, argv))
+ return FAIL;
if (**item == 'i')
printf(" %s\n", item[GI_INFO] + 1);
- else {
- /* TODO: Make simple getopt like function for these flags */
- if (argc == 2 && strchr(argv[1], 'n'))
- printf("%4d", ino);
- printf(" [%c] %s", item[GI_INFO][0], item[GI_INFO] + 1);
- if (argc == 2 && strchr(argv[1], 'v'))
- printf(" (%s%s)", item[GI_HOST], item[GI_PATH]);
- putchar('\n');
- }
+ else
+ printf("%4d [%c] %s [%s%s]\n", ino, item[GI_INFO][0],
+ item[GI_INFO] + 1, item[GI_HOST], item[GI_PATH]);
return PASS;
}
diff --git a/config.def.h b/config.def.h
@@ -8,7 +8,7 @@ static char *const default_address[] = { "/", "localhost", "70" };
static int timeout = 5 * 1000;
/* command which gets run when a file is cached */
-static const char cache_command[] = "p n";
+static const char cache_command[] = "p";
#define IFS0 ";\n" /* statement sep */
#define IFS1 "|" /* command sep */