Skip to content

Commit

Permalink
basic implementation of chump list
Browse files Browse the repository at this point in the history
  • Loading branch information
nshaheed committed May 9, 2024
1 parent 43383ed commit 58f5985
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

void printLogo();
void printPackage(Package pkg);
void printPackages(Manager* mgr);

// Parse arguments into a (command, arguments[]) tuple
std::tuple<std::string, std::vector<std::string>> parseArgs( int argc, const char ** argv ) {
Expand Down Expand Up @@ -34,6 +35,13 @@ void execCommand(std::string cmd, std::vector<std::string> args, Manager* manage

printPackage(pkg.value());

} else if (cmd == "list") {
if (args.size() != 0) {
std::cerr << "\"chump list\" should have no arguments" << std::endl;
return;
}

printPackages(manager);
} else if (cmd == "install") {
// manager->fetch->fetch("https://ccrma.stanford.edu/~nshaheed/220a/hw4/hw4.wav");
// manager->fetch->fetch("https://ccrma.stanford.edu/~nshaheed/rave_models/chafe_cello.ts");
Expand All @@ -51,6 +59,13 @@ void printPackage(Package pkg) {
std::cout << pkg << std::endl;
}

void printPackages(Manager* mgr) {
vector<Package> packages = mgr->listPackages();
for (Package p: packages) {
std::cout << p.name << std::endl;
}
}


void printLogo() {
std::cout << std::endl;
Expand Down
1 change: 1 addition & 0 deletions include/package_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PackageList {

// return specific version of package
optional<PackageVersion> find_package_version(string name, string version);
std::vector<Package> get_packages();


/* static void from_json(const json& j, PackageList& pkg_list); */
Expand Down
4 changes: 4 additions & 0 deletions src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ bool Manager::uninstall(std::string packageName) {

return true;
}

std::vector<Package> Manager::listPackages() {
return package_list->get_packages();
}
4 changes: 4 additions & 0 deletions src/package_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ optional<PackageVersion> PackageList::find_package_version(string name, string v
return {};
}

std::vector<Package> PackageList::get_packages() {
return packages;
}

0 comments on commit 58f5985

Please sign in to comment.