Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ members = [".", "crates/*"]

[dependencies]
blake3 = { version = "1.5.0", features = ["mmap", "rayon", "serde"] }
camino = "1.0.4"
camino = { version = "1.0.4", features = ["serde1"] }
chrono = "0.4.38"
clap = { version = "4.0.0", features = ["derive", "env", "string", "wrap_help"] }
clap_complete = { version = "=4.6.8", features = ["unstable-dynamic"] }
Expand Down
18 changes: 9 additions & 9 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ pub(crate) struct Analyzer<'run, 'src> {

impl<'run, 'src> Analyzer<'run, 'src> {
pub(crate) fn analyze(
asts: &'run HashMap<(Modulepath, PathBuf), Ast<'src>>,
asts: &'run HashMap<(Modulepath, Utf8PathBuf), Ast<'src>>,
config: &Config,
doc: Option<String>,
groups: &[StringLiteral<'src>],
loaded: &[PathBuf],
loaded: &[Utf8PathBuf],
module_path: &Modulepath,
name: Option<Name<'src>>,
overrides: &mut HashMap<Number, String>,
paths: &HashMap<PathBuf, PathBuf>,
paths: &HashMap<Utf8PathBuf, Utf8PathBuf>,
private: bool,
root: &Path,
root: &Utf8Path,
) -> CompileResult<'src, Justfile<'src>> {
Self::default().justfile(
asts,
Expand All @@ -43,17 +43,17 @@ impl<'run, 'src> Analyzer<'run, 'src> {

fn justfile(
mut self,
asts: &'run HashMap<(Modulepath, PathBuf), Ast<'src>>,
asts: &'run HashMap<(Modulepath, Utf8PathBuf), Ast<'src>>,
config: &Config,
doc: Option<String>,
groups: &[StringLiteral<'src>],
loaded: &[PathBuf],
loaded: &[Utf8PathBuf],
module_path: &Modulepath,
name: Option<Name<'src>>,
overrides: &mut HashMap<Number, String>,
paths: &HashMap<PathBuf, PathBuf>,
paths: &HashMap<Utf8PathBuf, Utf8PathBuf>,
private: bool,
root: &Path,
root: &Utf8Path,
) -> CompileResult<'src, Justfile<'src>> {
let mut absent_modules = BTreeSet::new();
let mut definitions = HashMap::new();
Expand Down Expand Up @@ -612,7 +612,7 @@ mod tests {
length: 3,
line: 0,
offset: 13,
path: Path::new("justfile"),
path: Utf8Path::new("justfile"),
src: "alias foo := bar\n",
}
))
Expand Down
15 changes: 7 additions & 8 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Arguments {
help = "Do not ascend above <CEILING> directory when searching for a justfile.",
long,
)]
pub(crate) ceiling: Option<PathBuf>,
pub(crate) ceiling: Option<Utf8PathBuf>,
#[arg(
help = "Run `--fmt` in 'check' mode. Exits with 0 if justfile is formatted correctly. \
Exits with 1 and prints a diff if formatting is required.",
Expand All @@ -68,7 +68,7 @@ pub struct Arguments {
help = "Override binary invoked by `--choose`",
long
)]
pub(crate) chooser: Option<PathBuf>,
pub(crate) chooser: Option<Utf8PathBuf>,
#[arg(help = "Clear shell arguments", long, overrides_with = "shell_arg")]
pub(crate) clear_shell_args: bool,
#[arg(
Expand Down Expand Up @@ -99,7 +99,7 @@ pub struct Arguments {
help = "Use binary at <CYGPATH> to convert between unix and Windows paths",
long,
)]
pub(crate) cygpath: PathBuf,
pub(crate) cygpath: Utf8PathBuf,
#[arg(
env = "JUST_DEFAULT_LIST",
help = "List recipes when no arguments are provided",
Expand Down Expand Up @@ -205,7 +205,7 @@ pub struct Arguments {
long,
short = 'f',
)]
pub(crate) justfile: Option<PathBuf>,
pub(crate) justfile: Option<Utf8PathBuf>,
#[arg(
env = "JUST_JUSTFILE_NAME",
help = "Search for justfile named <NAME>, accepts multiple `,`-separated values and may be \
Expand Down Expand Up @@ -303,7 +303,7 @@ pub struct Arguments {
help = "Save temporary files to <TEMPDIR>.",
long,
)]
pub(crate) tempdir: Option<PathBuf>,
pub(crate) tempdir: Option<Utf8PathBuf>,
#[arg(env = "JUST_TIME", help = "Print recipe execution time", long)]
pub(crate) time: bool,
#[arg(env = "JUST_TIMESTAMP", help = "Print recipe command timestamps", long)]
Expand Down Expand Up @@ -345,7 +345,7 @@ pub struct Arguments {
requires = "justfile",
short = 'd',
)]
pub(crate) working_directory: Option<PathBuf>,
pub(crate) working_directory: Option<Utf8PathBuf>,
#[arg(env = "JUST_YES", help = "Automatically confirm all recipes.", long)]
pub(crate) yes: bool,
}
Expand Down Expand Up @@ -383,9 +383,8 @@ pub(crate) struct Subcommand {
long,
num_args = 1..,
short = 'c',
value_parser = clap::value_parser!(OsString),
)]
pub(crate) command: Option<Vec<OsString>>,
pub(crate) command: Option<Vec<String>>,
#[arg(
help = "Print shell completion script for <SHELL>",
help_heading = Self::HEADING,
Expand Down
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(crate) struct Ast<'src> {
pub(crate) module_path: Modulepath,
pub(crate) unstable_features: BTreeSet<UnstableFeature>,
pub(crate) warnings: Vec<Warning>,
pub(crate) working_directory: PathBuf,
pub(crate) working_directory: Utf8PathBuf,
}

impl Ast<'_> {
Expand Down
10 changes: 5 additions & 5 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const DIR: &str = ".justcache";

pub(crate) struct Cache {
initialized: Mutex<bool>,
path: PathBuf,
path: Utf8PathBuf,
}

impl Cache {
pub(crate) fn status(
&self,
config: &Config,
key: CacheKey,
outputs: &BTreeMap<String, PathBuf>,
outputs: &BTreeMap<String, Utf8PathBuf>,
) -> RunResult<'static, CacheStatus> {
let mut hasher = blake3::Hasher::new();

Expand Down Expand Up @@ -77,7 +77,7 @@ impl Cache {
}
}

fn entry(&self, key: blake3::Hash) -> RunResult<'static, PathBuf> {
fn entry(&self, key: blake3::Hash) -> RunResult<'static, Utf8PathBuf> {
let mut initialized = self.initialized.lock().unwrap();

if !*initialized {
Expand All @@ -93,7 +93,7 @@ impl Cache {

pub(crate) fn inputs(
value: Value,
working_directory: &Path,
working_directory: &Utf8Path,
) -> RunResult<'static, BTreeMap<String, blake3::Hash>> {
let mut inputs = BTreeMap::new();

Expand Down Expand Up @@ -127,7 +127,7 @@ impl Cache {
Ok(inputs)
}

pub(crate) fn dir(search: &Search) -> PathBuf {
pub(crate) fn dir(search: &Search) -> Utf8PathBuf {
search.justfile_parent().join(DIR)
}
}
2 changes: 1 addition & 1 deletion src/cache_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pub(crate) struct CacheKey<'a> {
pub(crate) inputs: Option<BTreeMap<String, blake3::Hash>>,
pub(crate) positional: Option<&'a [String]>,
pub(crate) recipe: &'a Modulepath,
pub(crate) working_directory: Option<&'a Path>,
pub(crate) working_directory: Option<&'a Utf8Path>,
}
2 changes: 1 addition & 1 deletion src/cache_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;

pub(crate) struct CacheLock {
pub(crate) file: File,
pub(crate) path: PathBuf,
pub(crate) path: Utf8PathBuf,
pub(crate) recipe: Modulepath,
}

Expand Down
10 changes: 5 additions & 5 deletions src/clean.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::*;

pub(crate) trait Clean {
fn clean(self) -> PathBuf;
fn clean(self) -> Utf8PathBuf;
}

impl Clean for &Path {
fn clean(self) -> PathBuf {
use Component::*;
impl Clean for &Utf8Path {
fn clean(self) -> Utf8PathBuf {
use Utf8Component::*;

let mut components = Vec::new();

Expand Down Expand Up @@ -39,7 +39,7 @@ mod tests {

#[track_caller]
fn case(path: &str, expected: &str) {
assert_eq!(Path::new(path).clean(), Path::new(expected));
assert_eq!(Utf8Path::new(path).clean(), Utf8Path::new(expected));
}

#[test]
Expand Down
16 changes: 8 additions & 8 deletions src/command_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pub(crate) trait CommandExt {

fn output_guard_stdout(self) -> Result<String, OutputError>;

fn resolve(program: impl AsRef<OsStr>) -> Command;
fn resolve(program: impl AsRef<str>) -> Command;

fn shell_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Command;
fn shell_arg(&mut self, arg: impl AsRef<str>) -> &mut Command;

fn status_guard(self) -> (io::Result<ExitStatus>, Option<Signal>);
}
Expand Down Expand Up @@ -39,8 +39,8 @@ impl CommandExt for Command {
)
}

fn resolve(program: impl AsRef<OsStr>) -> Self {
let program = Path::new(program.as_ref());
fn resolve(program: impl AsRef<str>) -> Self {
let program = Utf8Path::new(program.as_ref());

if !cfg!(windows) {
return Self::new(program);
Expand All @@ -49,7 +49,7 @@ impl CommandExt for Command {
let mut candidates = vec![program.into()];

let mut components = program.components();
if matches!(components.next(), Some(Component::Normal(_)))
if matches!(components.next(), Some(Utf8Component::Normal(_)))
&& components.next().is_none()
&& let Some(path) = env::var_os("PATH")
{
Expand Down Expand Up @@ -90,14 +90,14 @@ impl CommandExt for Command {
Self::new(program)
}

fn shell_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Command {
fn shell_arg(&mut self, arg: impl AsRef<str>) -> &mut Command {
#[cfg(windows)]
if ShellKind::from(&*self) == ShellKind::Cmd {
use std::os::windows::process::CommandExt;
return self.raw_arg(arg);
return self.raw_arg(arg.as_ref());
}

self.arg(arg)
self.arg(arg.as_ref())
}

fn status_guard(self) -> (io::Result<ExitStatus>, Option<Signal>) {
Expand Down
4 changes: 2 additions & 2 deletions src/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use super::*;

#[derive(Debug)]
pub(crate) struct Compilation<'src> {
pub(crate) asts: HashMap<(Modulepath, PathBuf), Ast<'src>>,
pub(crate) asts: HashMap<(Modulepath, Utf8PathBuf), Ast<'src>>,
pub(crate) justfile: Justfile<'src>,
pub(crate) overrides: HashMap<Number, String>,
pub(crate) root: PathBuf,
pub(crate) root: Utf8PathBuf,
}

impl<'src> Compilation<'src> {
Expand Down
Loading
Loading