-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Precise description of directory relations when searching upward for …
…spin.toml. Such precise, very great-grand. Signed-off-by: itowlson <ivan.towlson@fermyon.com>
- Loading branch information
Showing
9 changed files
with
115 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Human-readable descriptions for directory relationships, | ||
//! and helpers for standard display. | ||
|
||
use std::path::Path; | ||
|
||
fn parent_rel(distance: usize) -> String { | ||
match distance { | ||
0 => "".to_owned(), | ||
1 => "parent".to_owned(), | ||
2 => "grandparent".to_owned(), | ||
_ => format!("{}grandparent", "great-".repeat(distance - 2)), | ||
} | ||
} | ||
|
||
pub fn notify_if_nondefault_rel(manifest_file: &Path, distance: usize) { | ||
if distance > 0 { | ||
terminal::einfo!( | ||
"No 'spin.toml' in current directory.", | ||
"Using 'spin.toml' from {} directory ({})", | ||
parent_rel(distance), | ||
manifest_file.display(), | ||
); | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn ancestry_text_is_correct() { | ||
assert_eq!("parent", parent_rel(1)); | ||
assert_eq!("grandparent", parent_rel(2)); | ||
assert_eq!("great-grandparent", parent_rel(3)); | ||
assert_eq!("great-great-great-grandparent", parent_rel(5)); // I hope you're happy Lann | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod build_info; | ||
pub mod commands; | ||
mod directory_rels; | ||
pub(crate) mod opts; | ||
pub mod subprocess; | ||
|
||
|