aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-11-02 23:57:14 +0000
committerdam <dam@gudinoff>2022-11-02 23:57:14 +0000
commitd3542e9fc54a60f4c694f76729c51c279566eabc (patch)
tree70f0508fffcac57b5c6424ad917daacd473fa27b
parent8ee967a0d3f4afa5549793f85f088503e8f8f7c9 (diff)
downloadtask-time-tracker-d3542e9fc54a60f4c694f76729c51c279566eabc.tar.zst
task-time-tracker-d3542e9fc54a60f4c694f76729c51c279566eabc.zip
Added help text. Allowed to use simplified options.
-rw-r--r--main.c67
1 files changed, 59 insertions, 8 deletions
diff --git a/main.c b/main.c
index 416c040..b43f832 100644
--- a/main.c
+++ b/main.c
@@ -1114,23 +1114,68 @@ int main(int argc, char *argv[]) {
bool is_exit_requested = false;
for (unsigned idx = 1; idx < argc; idx++) {
+ is_action = false;
+ action = "-h";
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
action = "--help";
- is_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
if (is_action) {
- fprintf(stdout, "TO BE IMPLEMENTED\n"); // TODO
+ // TODO Maybe rearrange the order of the command.
+ fprintf(stdout,
+ "Usage: ttt [OPTION]... [FILE]...\n"
+ " -i, --import-csv [FILE] Imports CSV file to database. First row is discarded.\n"
+ " -e, --export-csv [FILE] Exports database to CSV file.\n"
+ " -n, --no-autosave Disable autosave feature. Only saves on exit.\n"
+ " -h, --help Display this help and exit.\n"
+ " -v, --version Output version information and exit.\n"
+ "\n"
+ "Commands\n"
+ " a, A Archives selected task (except if active).\n"
+ " u, U Unarchives selected task.\n"
+ " c, C Selectes currently active task.\n"
+ " d, D Duplicates selected task.\n"
+ " n, N Creates new task.\n"
+ " m, M Moves selected task to position.\n"
+ " g, G Selects task by position.\n"
+ " q, Q Saves changes and exits.\n"
+ " F2 Renames selected task.\n"
+ " F5 Recalculates total times.\n"
+ " TAB Toggles archive view.\n"
+ " BACKSPACE Resets times for selected task.\n"
+ " DELETE Deletes selected task (except if active).\n"
+ " SPACE, ENTER Toggles selected task as active/inactive.\n"
+ " 1, 2, 3, 4, 5, 6, 7 Edit time of current task for the Nth day of week.\n"
+ " UP Select task above.\n"
+ " DOWN Select task below.\n"
+ " PAGE-UP Select task 1 page above.\n"
+ " PAGE-DOWN Select task 1 page below.\n"
+ " HOME Select first/top task.\n"
+ " END Select last/bottom task.\n"
+ "\n"
+ "Notes\n"
+ " During intensive tasks such as, saving to file or recalculating totals times,\n"
+ " a diamond simbol is shown on the top left corner. This should only be visible\n"
+ " on databases with more than 1000000 tasks.\n"
+ );
return EXIT_SUCCESS;
}
+ is_action = false;
+ action = "-v";
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
action = "--version";
- is_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
if (is_action) {
- fprintf(stdout, "Task Time Tracker v" VERSION "\n");
+ fprintf(stdout, "Task Time Tracker version " VERSION "\n");
free_memory();
return EXIT_SUCCESS;
}
+ is_action = false;
+ action = "-i";
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
action = "--import-csv";
- is_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
if (is_action) {
idx++;
if (idx >= argc) {
@@ -1147,8 +1192,11 @@ int main(int argc, char *argv[]) {
continue;
}
+ is_action = false;
+ action = "-e";
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
action = "--export-csv";
- is_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
if (is_action) {
idx++;
if (idx >= argc) {
@@ -1164,8 +1212,11 @@ int main(int argc, char *argv[]) {
continue;
}
+ is_action = false;
+ action = "-n";
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
action = "--no-autosave";
- is_action = strncmp(argv[idx], action, strlen(action)+1) == 0;
+ is_action |= strncmp(argv[idx], action, strlen(action)+1) == 0;
if (is_action) {
is_autosave_enabled = false;
continue;
@@ -1191,7 +1242,7 @@ int main(int argc, char *argv[]) {
flushinp();
ungetch(KEY_RESIZE);
- for (int key; (key = getch()) != 'q'; ) {
+ for (int key; ((key = getch()) != 'q') && (key != 'Q'); ) {
static layout_st *layout = &layouts[L_COMPACT];
task_st *active_task = get_active_task(db);