From aa0d78815004ae6b0c4a42b0e024f5c4ef555ae2 Mon Sep 17 00:00:00 2001 From: dacctal Date: Sun, 24 May 2026 10:23:38 +0000 Subject: c rewrite --- src/cla_parse.cc | 83 -------------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/cla_parse.cc (limited to 'src/cla_parse.cc') diff --git a/src/cla_parse.cc b/src/cla_parse.cc deleted file mode 100644 index 76500fd..0000000 --- a/src/cla_parse.cc +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include -#include - -#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 "update_all.hh" -#include "vars.hh" - -#define COMMAND(large, small, code) \ - if (strcmp(argv[i], large) == 0 || strcmp(argv[i], small) == 0) \ - code -#define NOT_ENOUGH_ARGS(arg, next) \ - std::cout << print_error << "Not enough arguments! Try: `pkgit " << arg \ - << " [" << next << "]`" << std::endl - -void cla_parse(int argc, char **argv) { - Pkg pkg; - - if (!argv[1]) { - help(); - return; - } - - for (int i = 1; i < argc; i++) { - COMMAND("--large", "-l", { is_symlink_install = true; }); - COMMAND("add", "a", { - if (argv[i + 1]) { - add_repo(argv[i + 1], name_from_url(argv[i + 1])); - } else { - NOT_ENOUGH_ARGS(argv[i], "url"); - } - }); - COMMAND("build", "b", { - if (argv[i + 1]) { - if (argv[i + 2]) { - pkg = create_pkg(argv[i + 1], argv[i + 2]); - build(pkg); - } else { - pkg = create_pkg(argv[i + 1], "default"); - build(pkg); - } - } else { - pkg = create_pkg(".", "default"); - build(pkg); - } - }); - COMMAND("install", "i", { - if (argv[i + 1]) { - if (argv[i + 2]) { - pkg = create_pkg(argv[i + 1], argv[i + 2]); - install_pkg(pkg); - } else { - pkg = create_pkg(argv[i + 1], "default"); - install_pkg(pkg); - } - } else { - NOT_ENOUGH_ARGS(argv[i], "url/pkg"); - } - }); - COMMAND("remove", "r", { - pkg = create_pkg(argv[i + 1]); - if (argv[i + 1]) { - remove_pkg(pkg); - } else { - NOT_ENOUGH_ARGS(argv[i], "url/pkg"); - } - }); - COMMAND("update", "u", { update_all(); }); - COMMAND("list", "l", { list_pkgs(); }); - COMMAND("--version", "-v", { std::cout << version << std::endl; }); - COMMAND("--help", "-h", { help(); }); - } -} -- cgit v1.2.3