summaryrefslogtreecommitdiff
path: root/cmd/main.c
blob: 41014f32f3d4b76b96d2b1a62f5f9754ac8afdd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* This file is a part of todo
 *
 * Copyright (C) 2021  Robby Zambito
 *
 * todo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * todo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <stdlib.h>
#include <string.h>

#include "todo.h"

#define STREQ(a, b) (strcmp(a, b) == 0)

int main(int argc, char **argv) {
  if (argc == 1 || STREQ("list", argv[1])) {
    todo_list();
  } else if (STREQ("add", argv[1])) {
    todo_add(argc - 2, argv + 2);
  } else if (STREQ("rm", argv[1])) {
    todo_rm(argc - 2, argv + 2);
  } else if (STREQ("done", argv[1])) {
    todo_done(argc - 2, argv + 2);
  } else if (STREQ("raw", argv[1])) {
    todo_raw(argc - 2, argv + 2);
  } else if (STREQ("sort", argv[1])) {
    todo_sort();
  } else {
    todo_help();
  }

  return EXIT_SUCCESS;
}