Skip to content

Commit aa7e9ee

Browse files
author
nshaheed
committed
pretty printing updates
1 parent 1774e5f commit aa7e9ee

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

data/manifest.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"os": "linux",
187187
"files": [
188188
{
189-
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/test_package/1.0.0/doesnotexist.ck",
189+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/TestPackage/1.0.0/doesnotexist.ck",
190190
"local_dir": "./",
191191
"file_type": "package",
192192
"checksum": "3333"
@@ -208,7 +208,7 @@
208208
"os": "linux",
209209
"files": [
210210
{
211-
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/test_package/1.0.0/hello.ck",
211+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/TestPackage/1.0.0/hello.ck",
212212
"local_dir": "./",
213213
"file_type": "package",
214214
"checksum": "d9865523a214fbdc00eadcf4e07a2c23746fbcb0af4bdbfb4e700fcf33894ce2"
@@ -230,13 +230,13 @@
230230
"os": "linux",
231231
"files": [
232232
{
233-
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/test_package/2.0.0/hello.ck",
233+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/TestPackage/2.0.0/hello.ck",
234234
"local_dir": "./",
235235
"file_type": "package",
236236
"checksum": "729cca447b587fe2abff90c9b2f2a5b8313a19f4e564b9894a657784ec7027de"
237237
},
238238
{
239-
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/test_package/2.0.0/hello.ck",
239+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/TestPackage/2.0.0/hello.ck",
240240
"local_dir": "./",
241241
"file_type": "data",
242242
"checksum": "729cca447b587fe2abff90c9b2f2a5b8313a19f4e564b9894a657784ec7027de"
@@ -272,7 +272,7 @@
272272
"os": "linux",
273273
"files": [
274274
{
275-
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/test_package/1.0.0/hello.ck",
275+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/TestPackage/1.0.0/hello.ck",
276276
"local_dir": "./",
277277
"file_type": "package",
278278
"checksum": "d9865523a214fbdc00eadcf4e07a2c23746fbcb0af4bdbfb4e700fcf33894ce2"
@@ -290,7 +290,7 @@
290290
"os": "linux",
291291
"files": [
292292
{
293-
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/test_package/2.0.0/hello.ck",
293+
"url": "https://ccrma.stanford.edu/~nshaheed/chugins/TestPackage/2.0.0/hello.ck",
294294
"local_dir": "./dir",
295295
"file_type": "package",
296296
"checksum": "729cca447b587fe2abff90c9b2f2a5b8313a19f4e564b9894a657784ec7027de"

include/exec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void printPackagesMultiLine(Manager *mgr, bool print_installed) {
9292
}
9393

9494
std::cout << " │ └─ " << TC::green("Install Path: ", TRUE)
95-
<< install_path << std::endl;
95+
<< install_path.string() << std::endl;
9696
}
9797

9898
std::cout << " ├─ " << TC::blue("Latest Version: ", TRUE) << latest_version

include/fetch.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace fs = std::filesystem;
2626
class FetchBase {
2727
public:
2828
virtual ~FetchBase() = default;
29-
virtual bool fetch(string data, fs::path dir, Package package,
29+
virtual bool fetch(string data, fs::path dir, Package package, PackageVersion ver,
3030
fs::path temp_dir, FileType file_type,
3131
string checksum) = 0;
3232
virtual bool fetch_manifest(string url, fs::path dir) = 0;
@@ -38,8 +38,8 @@ class Fetch : public FetchBase {
3838
Fetch();
3939
Fetch(bool render_tui);
4040
// download a package file from a remote host
41-
bool fetch(string data, fs::path dir, Package package, fs::path temp_dir,
42-
FileType file_type, string checksum);
41+
bool fetch(string data, fs::path dir, Package package, PackageVersion ver,
42+
fs::path temp_dir, FileType file_type, string checksum);
4343
// download the manifest from a remote host
4444
bool fetch_manifest(string url, fs::path dir);
4545

src/fetch.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int progressCallback(void *clientp, double dltotal, double dlnow,
8787
// Download file to proper package directory.
8888
// Return true on success, False on failure.
8989
//*******************************************
90-
bool Fetch::fetch(std::string url, fs::path dir, Package package,
90+
bool Fetch::fetch(std::string url, fs::path dir, Package package, PackageVersion ver,
9191
fs::path temp_dir, FileType file_type, string checksum) {
9292
if (!isURL(url)) {
9393
std::cerr << "[chump]: not a URL!" << std::endl;
@@ -152,7 +152,7 @@ bool Fetch::fetch(std::string url, fs::path dir, Package package,
152152

153153
// Perform the request
154154
string line = TC::orange("down-chucking package", TRUE) + " ";
155-
line += TC::bold(package.name) + TC::orange(" ├─ ", TRUE) +
155+
line += TC::bold(package.name) + " (" + ver.getVersionString() + ")" + TC::orange(" ├─ ", TRUE) +
156156
filename.string() + "\n";
157157
std::cerr << line;
158158

src/manager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bool Manager::install(string packageName) {
9797
FileType file_type = file.file_type;
9898

9999
bool result =
100-
fetch->fetch(url, dir, package, temp_dir, file_type, checksum);
100+
fetch->fetch(url, dir, package, version, temp_dir, file_type, checksum);
101101
if (!result) {
102102
std::cerr << "[chump]: failed to fetch " << url << ", exiting."
103103
<< std::endl;
@@ -318,7 +318,7 @@ bool Manager::update(string packageName) {
318318
FileType file_type = file.file_type;
319319

320320
bool result =
321-
fetch->fetch(url, dir, package, temp_dir, file_type, checksum);
321+
fetch->fetch(url, dir, package, latest_version, temp_dir, file_type, checksum);
322322
if (!result) {
323323
std::cerr << "[chump]: failed to fetch " << url << ", exiting."
324324
<< std::endl;

tests/fetch_test.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ TEST_CASE("Check if a string is a valid URL", "[Fetch]") {
2121
TEST_CASE("Fetch::fetch() tests") {
2222
Fetch f;
2323
Package p;
24+
PackageVersion v;
2425
SECTION("Invalid URL") {
25-
REQUIRE_FALSE(f.fetch("badurl", "./", p, "/tmp/", PACKAGE_FILE, ""));
26+
REQUIRE_FALSE(f.fetch("badurl", "./", p, v, "/tmp/", PACKAGE_FILE, ""));
2627
}
2728
}

tests/integration.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,15 @@ TEST_CASE("Integration Tests - update manifest") {
245245
TEST_CASE("Integration Test - wrong checksum") {
246246
Fetch f;
247247
Package p;
248+
PackageVersion v;
248249

249250
fs::path tmpPath{fs::temp_directory_path() /= std::tmpnam(nullptr)};
250251
fs::create_directories(tmpPath);
251252

252253
// This will fail due to an incorrect checksum being provided
253254
bool result = f.fetch("https://ccrma.stanford.edu/~nshaheed/chugins/"
254-
"test_package/1.0.0/hello.ck",
255-
"./", p, tmpPath, PACKAGE_FILE, "1234");
255+
"TestPackage/1.0.0/hello.ck",
256+
"./", p, v, tmpPath, PACKAGE_FILE, "1234");
256257
REQUIRE_FALSE(result);
257258
}
258259

0 commit comments

Comments
 (0)