Skip to content

Commit 19cb00b

Browse files
committed
---
yaml --- r: 13751 b: refs/heads/try c: bd17319 h: refs/heads/master i: 13749: e3ee799 13747: a939991 13743: c4c2db0 v: v3
1 parent 6a681f9 commit 19cb00b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 73561264572c1412b88695bf2f9563bff36857ee
5+
refs/heads/try: bd17319b413258966368ea0926e8815d30add281
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/cargo/cargo.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,25 @@ fn install_package(c: cargo, wd: str, pkg: package) {
476476
}
477477
}
478478

479+
fn cargo_suggestion(c: cargo, syncing: bool, fallback: fn())
480+
{
481+
if c.sources.size() == 0u {
482+
error("No sources defined. You may wish to run " +
483+
"\"cargo init\" then \"cargo sync\".");
484+
ret;
485+
}
486+
if !syncing {
487+
let npkg = 0u;
488+
c.sources.values({ |v| npkg += vec::len(v.packages) });
489+
if npkg == 0u {
490+
error("No packages known. You may wish to run " +
491+
"\"cargo sync\".");
492+
ret;
493+
}
494+
}
495+
fallback();
496+
}
497+
479498
fn install_uuid(c: cargo, wd: str, uuid: str) {
480499
let ps = [];
481500
for_each_package(c, { |s, p|
@@ -489,7 +508,7 @@ fn install_uuid(c: cargo, wd: str, uuid: str) {
489508
install_package(c, wd, p);
490509
ret;
491510
} else if vec::len(ps) == 0u {
492-
error("No packages.");
511+
cargo_suggestion(c, false, { || error("No packages match uuid."); });
493512
ret;
494513
}
495514
error("Found multiple packages:");
@@ -510,7 +529,7 @@ fn install_named(c: cargo, wd: str, name: str) {
510529
install_package(c, wd, p);
511530
ret;
512531
} else if vec::len(ps) == 0u {
513-
error("No packages.");
532+
cargo_suggestion(c, false, { || error("No packages match name."); });
514533
ret;
515534
}
516535
error("Found multiple packages:");
@@ -651,6 +670,7 @@ fn cmd_sync(c: cargo, argv: [str]) {
651670
if vec::len(argv) == 3u {
652671
sync_one(c, argv[2], c.sources.get(argv[2]));
653672
} else {
673+
cargo_suggestion(c, true, { || } );
654674
c.sources.items { |k, v|
655675
sync_one(c, k, v);
656676
}

0 commit comments

Comments
 (0)