diff options
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | TODO.md | 2 | ||||
| -rw-r--r-- | include/cla_parse.hh | 4 | ||||
| -rwxr-xr-x | pkgit | bin | 284000 -> 221936 bytes | |||
| -rw-r--r-- | src/cla_parse.cc | 83 | ||||
| -rw-r--r-- | src/main.cc | 63 |
6 files changed, 90 insertions, 71 deletions
@@ -12,12 +12,3 @@ pkgit: src/main.cc install: pkgit install -d ${DESTDIR}${PREFIX}/bin install -m 755 pkgit ${DESTDIR}${PREFIX}/bin/pkgit - - -luatest: src/lua_build.cc - ${CC} -o luatest src/lua_build.cc ${CXXFLAGS} - chmod +x luatest - -repotest: src/setup_repo.cc - ${CC} -o repotest src/setup_repo.cc ${CXXFLAGS} - chmod +x repotest @@ -5,11 +5,11 @@ - [x] remove pkg - [x] lua build systems - [x] lua repos +- [x] CLA parsing - [ ] lua dependency listing - [ ] lua config primary(/etc) / secondary(.config) checks - [ ] lua variables for install paths - [ ] lua custom source fetching methods -- [ ] CLA parsing - [ ] version management - [ ] (maybe) diffs to change versions - [ ] (maybe) lua custom install methods for sandboxed builds diff --git a/include/cla_parse.hh b/include/cla_parse.hh new file mode 100644 index 0000000..893c887 --- /dev/null +++ b/include/cla_parse.hh @@ -0,0 +1,4 @@ +#ifndef CLA_PARSE +#define CLA_PARSE +void cla_parse(int argc, char** argv); +#endif Binary files differdiff --git a/src/cla_parse.cc b/src/cla_parse.cc new file mode 100644 index 0000000..ed29d2e --- /dev/null +++ b/src/cla_parse.cc @@ -0,0 +1,83 @@ +#include <string> +#include <cstring> +#include <filesystem> +#include <iostream> + +#include "cla_parse.hh" + +#include "add_repo.hh" +#include "build.hh" +#include "create_pkg.hh" +#include "help.hh" +#include "install_pkg.hh" +#include "list_pkgs.hh" +#include "name_from_url.hh" +#include "remove_pkg.hh" +#include "setup_pkgit.hh" +#include "update_all.hh" +#include "vars.hh" + +void cla_parse(int argc, char** argv) { + Pkg pkg; + + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--link") == 0 || strcmp(argv[i], "-l") == 0) { + is_symlink_install = true; + } + + if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { + is_verbose = true; + } + + if (strcmp(argv[i], "add") == 0 || strcmp(argv[i], "a") == 0) { + for (int j = i+1; i < argc; j++) { + if (argv[j]) { + add_repo(argv[j], name_from_url(argv[j])); + } else { + std::cout << print_error << "Not enough arguments! Try: `pkgit add [url]`"; + } + } + + } else if (strcmp(argv[i], "build") == 0 || strcmp(argv[i], "b") == 0) { + for (int j = i+1; i < argc; j++) { + if (argv[j]) { + build(argv[j]); + } else { + build(std::filesystem::current_path().string().c_str()); + } + } + + } else if (strcmp(argv[i], "install") == 0 || strcmp(argv[i], "i") == 0) { + for (int j = i+1; i < argc; j++) { + pkg = create_pkg(argv[j]); + if (argv[j]) { + install_pkg(pkg); + } else { + std::cout << print_error << "Not enough arguments! Try: `pkgit install [url/pkg]`"; + } + } + + } else if (strcmp(argv[i], "remove") == 0 || strcmp(argv[i], "r") == 0) { + for (int j = i+1; i < argc; j++) { + pkg = create_pkg(argv[j]); + if (argv[j]) { + remove_pkg(pkg); + } else { + std::cout << print_error << "Not enough arguments! Try: `pkgit remove [url/pkg]`"; + } + } + + } else if (strcmp(argv[i], "update") == 0 || strcmp(argv[i], "u") == 0) { + update_all(); + + } else if (strcmp(argv[i], "list") == 0 || strcmp(argv[i], "l") == 0) { + list_pkgs(); + + } else if (strcmp(argv[i], "help") == 0 || strcmp(argv[i], "h") == 0) { + help(); + + } else { + help(); + } + } +} diff --git a/src/main.cc b/src/main.cc index b732c1b..ecce36a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -3,75 +3,16 @@ #include <filesystem> #include <iostream> -#include "add_repo.hh" -#include "build.hh" -#include "create_pkg.hh" +#include "cla_parse.hh" #include "help.hh" -#include "install_pkg.hh" -#include "list_pkgs.hh" -#include "name_from_url.hh" -#include "remove_pkg.hh" #include "setup_pkgit.hh" -#include "update_all.hh" -#include "vars.hh" int main(int argc, char *argv[]) { setup_pkgit(); - Pkg pkg; if (!argv[1]) { help(); return 0; } - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--link") == 0 || strcmp(argv[i], "-l") == 0) { - is_symlink_install = true; - } - if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { - is_verbose = true; - } - } - - if (strcmp(argv[1], "add") == 0 || strcmp(argv[1], "a") == 0) { - if (argv[2]) { - add_repo(argv[2], name_from_url(argv[2])); - } else { - std::cout << print_error << "Not enough arguments! Try: `pkgit add [url]`"; - } - - } else if (strcmp(argv[1], "build") == 0 || strcmp(argv[1], "b") == 0) { - if (argv[2]) { - build(argv[2]); - } else { - build(std::filesystem::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/pkg]`"; - } - - } else if (strcmp(argv[1], "remove") == 0 || strcmp(argv[1], "r") == 0) { - pkg = create_pkg(argv[2]); - if (argv[2]) { - remove_pkg(pkg); - } else { - std::cout << print_error << "Not enough arguments! Try: `pkgit remove [url/pkg]`"; - } - - } else if (strcmp(argv[1], "update") == 0 || strcmp(argv[1], "u") == 0) { - update_all(); - - } else if (strcmp(argv[1], "list") == 0 || strcmp(argv[1], "l") == 0) { - list_pkgs(); - - } else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "h") == 0) { - help(); - - } else { - help(); - } + cla_parse(argc, argv); return 0; } |
