Skip to content

Commit

Permalink
Add WithStdin variants to SearchConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Drzymala committed May 15, 2024
1 parent a9b0912 commit 2b3bed9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,22 @@ mod tests {
},
}

test! {
name: search_config_from_working_directory_and_justfile_long_stdin,
args: ["--working-directory", "foo", "--justfile", "-"],
search_config: SearchConfig::WithStdinAndWorkingDirectory {
working_directory: PathBuf::from("foo"),
},
}

test! {
name: search_config_from_working_directory_and_justfile_short_stdin,
args: ["--working-directory", "foo", "-f", "-"],
search_config: SearchConfig::WithStdinAndWorkingDirectory {
working_directory: PathBuf::from("foo"),
},
}

test! {
name: search_config_justfile_long,
args: ["--justfile", "foo"],
Expand All @@ -1384,6 +1400,12 @@ mod tests {
},
}

test! {
name: search_config_justfile_long_stdin,
args: ["--justfile", "-"],
search_config: SearchConfig::WithStdin,
}

test! {
name: search_config_justfile_short,
args: ["-f", "foo"],
Expand All @@ -1392,6 +1414,12 @@ mod tests {
},
}

test! {
name: search_config_justfile_short_stdin,
args: ["-f", "-"],
search_config: SearchConfig::WithStdin,
}

test! {
name: search_directory_parent,
args: ["../"],
Expand Down
6 changes: 6 additions & 0 deletions src/search_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ pub(crate) enum SearchConfig {
justfile: PathBuf,
working_directory: PathBuf,
},
/// Use justfile loaded from stdin by using "-" as justfile name.
WithStdin,
/// Use justfile loaded from stdin and working directory.
WithStdinAndWorkingDirectory {
working_directory: PathBuf,
},
}

0 comments on commit 2b3bed9

Please sign in to comment.