Skip to content

Commit

Permalink
Merge pull request #1262 from pi-hole/new/human_readable_tables
Browse files Browse the repository at this point in the history
Add human-readable table output mode
  • Loading branch information
DL6ER authored Dec 26, 2021
2 parents 8a11adb + db153cc commit 106ef8c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,26 @@ void parse_args(int argc, char* argv[])
if(strcmp(argv[i], "sql") == 0 ||
strcmp(argv[i], "sqlite3") == 0 ||
strcmp(argv[i], "--sqlite3") == 0)
{
// Human-readable table output mode
if(i+1 < argc && strcmp(argv[i+1], "-h") == 0)
{
int argc2 = argc - i + 5 - 2;
char **argv2 = calloc(argc2, sizeof(char*));
argv2[0] = argv[0]; // Application name
argv2[1] = (char*)"-column";
argv2[2] = (char*)"-header";
argv2[3] = (char*)"-nullvalue";
argv2[4] = (char*)"(null)";
// i = "sqlite3"
// i+1 = "-h"
for(int j = 0; j < argc - i - 2; j++)
argv2[5 + j] = argv[i + 2 + j];
exit(sqlite3_shell_main(argc2, argv2));
}
else
exit(sqlite3_shell_main(argc - i, &argv[i]));
}

// Implement dnsmasq's test function, no need to prepare the entire FTL
// environment (initialize shared memory, lead queries from long-term
Expand Down Expand Up @@ -322,7 +341,8 @@ void parse_args(int argc, char* argv[])
printf("\t--luac, luac FTL's lua compiler\n");
printf("\tdhcp-discover Discover DHCP servers in the local\n");
printf("\t network\n");
printf("\tsqlite3 FTL's SQLite3 shell\n");
printf("\tsql, sqlite3 FTL's SQLite3 shell\n");
printf("\tsql -h, sqlite3 -h FTL's SQLite3 shell (human-readable mode)\n");
printf("\n\nOnline help: https://github.com/pi-hole/FTL\n");
exit(EXIT_SUCCESS);
}
Expand Down

0 comments on commit 106ef8c

Please sign in to comment.