summaryrefslogtreecommitdiff
path: root/cli/args/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r--cli/args/flags.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 8b796edc2..a05d31ce1 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -34,6 +34,35 @@ pub struct FileFlags {
pub include: Vec<PathBuf>,
}
+impl FileFlags {
+ pub fn with_absolute_paths(self, base: &Path) -> Self {
+ fn to_absolute_path(path: PathBuf, base: &Path) -> PathBuf {
+ // todo(dsherret): don't store URLs in PathBufs
+ if path.starts_with("http:")
+ || path.starts_with("https:")
+ || path.starts_with("file:")
+ {
+ path
+ } else {
+ base.join(path)
+ }
+ }
+
+ Self {
+ include: self
+ .include
+ .into_iter()
+ .map(|p| to_absolute_path(p, base))
+ .collect(),
+ ignore: self
+ .ignore
+ .into_iter()
+ .map(|p| to_absolute_path(p, base))
+ .collect(),
+ }
+ }
+}
+
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct BenchFlags {
pub files: FileFlags,