diff options
| author | dacctal <dacctal@symlinx.net> | 2026-05-24 10:23:38 +0000 |
|---|---|---|
| committer | dacctal <dacctal@symlinx.net> | 2026-05-24 10:23:38 +0000 |
| commit | aa0d78815004ae6b0c4a42b0e024f5c4ef555ae2 (patch) | |
| tree | 62f97b4c5acfdb98003568466f878fbd3d6b9dfb /src/cla_parse.cc | |
| parent | 83d471f2c1d1b1fa6be51f41e4f1c36ab19d7094 (diff) | |
c rewrite
Diffstat (limited to 'src/cla_parse.cc')
| -rw-r--r-- | src/cla_parse.cc | 83 |
1 files changed, 0 insertions, 83 deletions
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 <cstring> -#include <filesystem> -#include <iostream> -#include <string> - -#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(); }); - } -} |
