aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
blob: bcc45df920794eb34e252e2ddb62a5a2e6ebe6fd (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
#include <string>
#include <cstring>
#include <filesystem>

#include "create_pkg.cc"
#include "help.cc"
#include "setup_pkgit.cc"
#include "install_pkg.cc"

int main(int argc, char *argv[]) {
  setup_pkgit();
  Pkg pkg;

  if (argv[1]) {
    if (strcmp(argv[1], "build") == 0 || strcmp(argv[1], "b") == 0) {
      if (argv[2]) {
        build(argv[2]);
      } else {
        build(fs::current_path().string().c_str());
      }
    } else if (strcmp(argv[1], "install") == 0 || strcmp(argv[1], "i") == 0) {
      pkg = create_pkg(argv[2]);
      if (argv[2]) {
        install_pkg(pkg);
      } else {
        std::cout << print_error << "Not enough arguments! Try: `pkgit install [url]`";
      }
    } else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "h") == 0) {
      help();
    } else if (strcmp(argv[1], "type") == 0) {
      link_install(fs::current_path().string());
    } else {
      help();
    }
  } else {
    help();
  }

  return 0;
}