Compare commits
No commits in common. "8d80f83795834ee9d9f7b03c010295a6b5e77e7e" and "1c3c1dd3c0802bf77c0e388ee331d00ceb68cf78" have entirely different histories.
8d80f83795
...
1c3c1dd3c0
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@ -95,7 +95,7 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
- name: Publish Archive
|
||||
uses: softprops/action-gh-release@v2.0.6
|
||||
uses: softprops/action-gh-release@v2.0.5
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
draft: false
|
||||
@ -105,7 +105,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish Changelog
|
||||
uses: softprops/action-gh-release@v2.0.6
|
||||
uses: softprops/action-gh-release@v2.0.5
|
||||
if: >-
|
||||
${{
|
||||
startsWith(github.ref, 'refs/tags/')
|
||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -306,6 +306,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cradle"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7096122c1023d53de7298f322590170540ad3eba46bbc2750b495f098c27c09a"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.5"
|
||||
@ -600,6 +609,7 @@ dependencies = [
|
||||
"clap 4.5.7",
|
||||
"clap_complete",
|
||||
"clap_mangen",
|
||||
"cradle",
|
||||
"ctrlc",
|
||||
"derivative",
|
||||
"dirs",
|
||||
|
@ -54,6 +54,7 @@ unicode-width = "0.1.0"
|
||||
uuid = { version = "1.0.0", features = ["v4"] }
|
||||
|
||||
[dev-dependencies]
|
||||
cradle = "0.2.0"
|
||||
executable-path = "1.0.0"
|
||||
pretty_assertions = "1.0.0"
|
||||
temptree = "0.2.0"
|
||||
|
26
README.md
26
README.md
@ -1642,16 +1642,6 @@ which will halt execution.
|
||||
characters. For example, `choose('64', HEX)` will generate a random
|
||||
64-character lowercase hex string.
|
||||
|
||||
#### Datetime
|
||||
|
||||
- `datetime(format)`<sup>master</sup> - Return local time with `format`.
|
||||
- `datetime_utc(format)`<sup>master</sup> - Return UTC time with `format`.
|
||||
|
||||
The arguments to `datetime` and `datetime_utc` are `strftime`-style format
|
||||
strings, see the
|
||||
[`chrono` library docs](https://docs.rs/chrono/latest/chrono/format/strftime/index.html)
|
||||
for details.
|
||||
|
||||
#### Semantic Versions
|
||||
|
||||
- `semver_matches(version, requirement)`<sup>1.16.0</sup> - Check whether a
|
||||
@ -3668,22 +3658,6 @@ ls:
|
||||
echo '{{absolute_path(".")}}'
|
||||
```
|
||||
|
||||
### Remote Justfiles
|
||||
|
||||
If you wish to include a `mod` or `import` source file in many `justfiles`
|
||||
without needing to duplicate it, you can use an optional `mod` or `import`,
|
||||
along with a recipe to fetch the module source:
|
||||
|
||||
```just
|
||||
import? 'foo.just'
|
||||
|
||||
fetch:
|
||||
curl https://raw.githubusercontent.com/casey/just/master/justfile > foo.just
|
||||
```
|
||||
|
||||
Given the above `justfile`, after running `just fetch`, the recipes in
|
||||
`foo.just` will be available.
|
||||
|
||||
### Alternatives and Prior Art
|
||||
|
||||
There is no shortage of command runners! Some more or less similar alternatives
|
||||
|
@ -3,7 +3,7 @@ use super::*;
|
||||
/// An alias, e.g. `name := target`
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
pub(crate) struct Alias<'src, T = Rc<Recipe<'src>>> {
|
||||
pub(crate) attributes: AttributeSet<'src>,
|
||||
pub(crate) attributes: BTreeSet<Attribute<'src>>,
|
||||
pub(crate) name: Name<'src>,
|
||||
#[serde(
|
||||
bound(serialize = "T: Keyed<'src>"),
|
||||
|
@ -79,15 +79,7 @@ impl<'src> Analyzer<'src> {
|
||||
assignments.push(assignment);
|
||||
}
|
||||
Item::Comment(_) => (),
|
||||
Item::Import {
|
||||
absolute,
|
||||
attributes,
|
||||
..
|
||||
} => {
|
||||
//TODO check attributes for validity
|
||||
|
||||
let _groups = attributes.groups();
|
||||
|
||||
Item::Import { absolute, .. } => {
|
||||
if let Some(absolute) = absolute {
|
||||
stack.push(asts.get(absolute).unwrap());
|
||||
}
|
||||
@ -157,7 +149,7 @@ impl<'src> Analyzer<'src> {
|
||||
}
|
||||
}
|
||||
|
||||
let recipes = RecipeResolver::resolve_recipes(&self.assignments, &settings, recipe_table)?;
|
||||
let recipes = RecipeResolver::resolve_recipes(recipe_table, &self.assignments)?;
|
||||
|
||||
let mut aliases = Table::new();
|
||||
while let Some(alias) = self.aliases.pop() {
|
||||
@ -239,7 +231,7 @@ impl<'src> Analyzer<'src> {
|
||||
fn analyze_alias(alias: &Alias<'src, Name<'src>>) -> CompileResult<'src> {
|
||||
let name = alias.name.lexeme();
|
||||
|
||||
for attribute in &alias.attributes.inner {
|
||||
for attribute in &alias.attributes {
|
||||
if *attribute != Attribute::Private {
|
||||
return Err(alias.name.token.error(AliasInvalidAttribute {
|
||||
alias: name,
|
||||
|
@ -120,49 +120,6 @@ impl<'src> Display for Attribute<'src> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
pub(crate) struct AttributeSet<'src> {
|
||||
#[serde(flatten)]
|
||||
pub(crate) inner: BTreeSet<Attribute<'src>>,
|
||||
}
|
||||
|
||||
impl<'src> AttributeSet<'src> {
|
||||
pub(crate) fn empty() -> Self {
|
||||
Self {
|
||||
inner: BTreeSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_map<T>(input: BTreeMap<Attribute<'src>, T>) -> Self {
|
||||
Self {
|
||||
inner: input.into_keys().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn to_btree_set(self) -> BTreeSet<Attribute<'src>> {
|
||||
self.inner
|
||||
}
|
||||
|
||||
pub(crate) fn contains(&self, attribute: &Attribute) -> bool {
|
||||
self.inner.contains(attribute)
|
||||
}
|
||||
|
||||
/// Get the names of all Group attributes defined in this attribute set
|
||||
pub(crate) fn groups(&self) -> Vec<&StringLiteral<'src>> {
|
||||
self
|
||||
.inner
|
||||
.iter()
|
||||
.filter_map(|attr| {
|
||||
if let Attribute::Group(name) = attr {
|
||||
Some(name)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -79,7 +79,6 @@ impl Compiler {
|
||||
absolute,
|
||||
optional,
|
||||
path,
|
||||
attributes: _,
|
||||
} => {
|
||||
let import = current
|
||||
.path
|
||||
|
@ -47,8 +47,6 @@ pub(crate) fn get(name: &str) -> Option<Function> {
|
||||
"config_local_directory" => Nullary(|_| dir("local config", dirs::config_local_dir)),
|
||||
"data_directory" => Nullary(|_| dir("data", dirs::data_dir)),
|
||||
"data_local_directory" => Nullary(|_| dir("local data", dirs::data_local_dir)),
|
||||
"datetime" => Unary(datetime),
|
||||
"datetime_utc" => Unary(datetime_utc),
|
||||
"encode_uri_component" => Unary(encode_uri_component),
|
||||
"env" => UnaryOpt(env),
|
||||
"env_var" => Unary(env_var),
|
||||
@ -237,14 +235,6 @@ fn dir(name: &'static str, f: fn() -> Option<PathBuf>) -> FunctionResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn datetime(_context: Context, format: &str) -> FunctionResult {
|
||||
Ok(chrono::Local::now().format(format).to_string())
|
||||
}
|
||||
|
||||
fn datetime_utc(_context: Context, format: &str) -> FunctionResult {
|
||||
Ok(chrono::Utc::now().format(format).to_string())
|
||||
}
|
||||
|
||||
fn encode_uri_component(_context: Context, s: &str) -> FunctionResult {
|
||||
static PERCENT_ENCODE: percent_encoding::AsciiSet = percent_encoding::NON_ALPHANUMERIC
|
||||
.remove(b'-')
|
||||
|
@ -7,7 +7,6 @@ pub(crate) enum Item<'src> {
|
||||
Assignment(Assignment<'src>),
|
||||
Comment(&'src str),
|
||||
Import {
|
||||
attributes: AttributeSet<'src>,
|
||||
absolute: Option<PathBuf>,
|
||||
optional: bool,
|
||||
path: Token<'src>,
|
||||
|
114
src/lib.rs
114
src/lib.rs
@ -13,99 +13,31 @@
|
||||
overlapping_range_endpoints
|
||||
)]
|
||||
|
||||
//! `just` is primarily used as a command-line binary, but does provide a
|
||||
//! limited public library interface.
|
||||
//!
|
||||
//! Please keep in mind that there are no semantic version guarantees for the
|
||||
//! library interface. It may break or change at any time.
|
||||
|
||||
pub(crate) use {
|
||||
crate::{
|
||||
alias::Alias,
|
||||
analyzer::Analyzer,
|
||||
argument_parser::ArgumentParser,
|
||||
assignment::Assignment,
|
||||
assignment_resolver::AssignmentResolver,
|
||||
ast::Ast,
|
||||
attribute::{Attribute, AttributeSet},
|
||||
binding::Binding,
|
||||
color::Color,
|
||||
color_display::ColorDisplay,
|
||||
command_ext::CommandExt,
|
||||
compilation::Compilation,
|
||||
compile_error::CompileError,
|
||||
compile_error_kind::CompileErrorKind,
|
||||
compiler::Compiler,
|
||||
condition::Condition,
|
||||
conditional_operator::ConditionalOperator,
|
||||
config::Config,
|
||||
config_error::ConfigError,
|
||||
constants::constants,
|
||||
count::Count,
|
||||
delimiter::Delimiter,
|
||||
dependency::Dependency,
|
||||
dump_format::DumpFormat,
|
||||
enclosure::Enclosure,
|
||||
error::Error,
|
||||
evaluator::Evaluator,
|
||||
execution_context::ExecutionContext,
|
||||
expression::Expression,
|
||||
fragment::Fragment,
|
||||
function::Function,
|
||||
interrupt_guard::InterruptGuard,
|
||||
interrupt_handler::InterruptHandler,
|
||||
item::Item,
|
||||
justfile::Justfile,
|
||||
keyed::Keyed,
|
||||
keyword::Keyword,
|
||||
lexer::Lexer,
|
||||
line::Line,
|
||||
list::List,
|
||||
load_dotenv::load_dotenv,
|
||||
loader::Loader,
|
||||
module_path::ModulePath,
|
||||
name::Name,
|
||||
namepath::Namepath,
|
||||
ordinal::Ordinal,
|
||||
output::output,
|
||||
output_error::OutputError,
|
||||
parameter::Parameter,
|
||||
parameter_kind::ParameterKind,
|
||||
parser::Parser,
|
||||
platform::Platform,
|
||||
platform_interface::PlatformInterface,
|
||||
position::Position,
|
||||
positional::Positional,
|
||||
ran::Ran,
|
||||
range_ext::RangeExt,
|
||||
recipe::Recipe,
|
||||
recipe_resolver::RecipeResolver,
|
||||
recipe_signature::RecipeSignature,
|
||||
scope::Scope,
|
||||
search::Search,
|
||||
search_config::SearchConfig,
|
||||
search_error::SearchError,
|
||||
set::Set,
|
||||
setting::Setting,
|
||||
settings::Settings,
|
||||
shebang::Shebang,
|
||||
shell::Shell,
|
||||
show_whitespace::ShowWhitespace,
|
||||
source::Source,
|
||||
string_kind::StringKind,
|
||||
string_literal::StringLiteral,
|
||||
subcommand::Subcommand,
|
||||
suggestion::Suggestion,
|
||||
table::Table,
|
||||
thunk::Thunk,
|
||||
token::Token,
|
||||
token_kind::TokenKind,
|
||||
unresolved_dependency::UnresolvedDependency,
|
||||
unresolved_recipe::UnresolvedRecipe,
|
||||
use_color::UseColor,
|
||||
variables::Variables,
|
||||
verbosity::Verbosity,
|
||||
warning::Warning,
|
||||
alias::Alias, analyzer::Analyzer, argument_parser::ArgumentParser, assignment::Assignment,
|
||||
assignment_resolver::AssignmentResolver, ast::Ast, attribute::Attribute, binding::Binding,
|
||||
color::Color, color_display::ColorDisplay, command_ext::CommandExt, compilation::Compilation,
|
||||
compile_error::CompileError, compile_error_kind::CompileErrorKind, compiler::Compiler,
|
||||
condition::Condition, conditional_operator::ConditionalOperator, config::Config,
|
||||
config_error::ConfigError, constants::constants, count::Count, delimiter::Delimiter,
|
||||
dependency::Dependency, dump_format::DumpFormat, enclosure::Enclosure, error::Error,
|
||||
evaluator::Evaluator, execution_context::ExecutionContext, expression::Expression,
|
||||
fragment::Fragment, function::Function, interrupt_guard::InterruptGuard,
|
||||
interrupt_handler::InterruptHandler, item::Item, justfile::Justfile, keyed::Keyed,
|
||||
keyword::Keyword, lexer::Lexer, line::Line, list::List, load_dotenv::load_dotenv,
|
||||
loader::Loader, module_path::ModulePath, name::Name, namepath::Namepath, ordinal::Ordinal,
|
||||
output::output, output_error::OutputError, parameter::Parameter, parameter_kind::ParameterKind,
|
||||
parser::Parser, platform::Platform, platform_interface::PlatformInterface, position::Position,
|
||||
positional::Positional, ran::Ran, range_ext::RangeExt, recipe::Recipe,
|
||||
recipe_resolver::RecipeResolver, recipe_signature::RecipeSignature, scope::Scope,
|
||||
search::Search, search_config::SearchConfig, search_error::SearchError, set::Set,
|
||||
setting::Setting, settings::Settings, shebang::Shebang, shell::Shell,
|
||||
show_whitespace::ShowWhitespace, source::Source, string_kind::StringKind,
|
||||
string_literal::StringLiteral, subcommand::Subcommand, suggestion::Suggestion, table::Table,
|
||||
thunk::Thunk, token::Token, token_kind::TokenKind, unresolved_dependency::UnresolvedDependency,
|
||||
unresolved_recipe::UnresolvedRecipe, use_color::UseColor, variables::Variables,
|
||||
verbosity::Verbosity, warning::Warning,
|
||||
},
|
||||
camino::Utf8Path,
|
||||
derivative::Derivative,
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
if let Err(code) = just::run(std::env::args_os()) {
|
||||
if let Err(code) = just::run() {
|
||||
std::process::exit(code);
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
} else if self.next_is(Identifier) {
|
||||
match Keyword::from_lexeme(next.lexeme()) {
|
||||
Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, ColonEquals]) => {
|
||||
items.push(Item::Alias(self.parse_alias(AttributeSet::empty())?));
|
||||
items.push(Item::Alias(self.parse_alias(BTreeSet::new())?));
|
||||
}
|
||||
Some(Keyword::Export) if self.next_are(&[Identifier, Identifier, ColonEquals]) => {
|
||||
self.presume_keyword(Keyword::Export)?;
|
||||
@ -354,7 +354,15 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
|| self.next_are(&[Identifier, Identifier, StringToken])
|
||||
|| self.next_are(&[Identifier, QuestionMark]) =>
|
||||
{
|
||||
items.push(self.parse_import(AttributeSet::empty())?);
|
||||
self.presume_keyword(Keyword::Import)?;
|
||||
let optional = self.accepted(QuestionMark)?;
|
||||
let (path, relative) = self.parse_string_literal_token()?;
|
||||
items.push(Item::Import {
|
||||
absolute: None,
|
||||
optional,
|
||||
path,
|
||||
relative,
|
||||
});
|
||||
}
|
||||
Some(Keyword::Mod)
|
||||
if self.next_are(&[Identifier, Identifier, StringToken])
|
||||
@ -400,7 +408,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
items.push(Item::Recipe(self.parse_recipe(
|
||||
doc,
|
||||
false,
|
||||
AttributeSet::empty(),
|
||||
BTreeSet::new(),
|
||||
)?));
|
||||
}
|
||||
}
|
||||
@ -410,7 +418,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
items.push(Item::Recipe(self.parse_recipe(
|
||||
doc,
|
||||
true,
|
||||
AttributeSet::empty(),
|
||||
BTreeSet::new(),
|
||||
)?));
|
||||
} else if let Some(attributes) = self.parse_attributes()? {
|
||||
let next_keyword = Keyword::from_lexeme(self.next()?.lexeme());
|
||||
@ -418,13 +426,6 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, ColonEquals]) => {
|
||||
items.push(Item::Alias(self.parse_alias(attributes)?));
|
||||
}
|
||||
Some(Keyword::Import)
|
||||
if self.next_are(&[Identifier, StringToken])
|
||||
|| self.next_are(&[Identifier, Identifier, StringToken])
|
||||
|| self.next_are(&[Identifier, QuestionMark]) =>
|
||||
{
|
||||
items.push(self.parse_import(attributes)?);
|
||||
}
|
||||
_ => {
|
||||
let quiet = self.accepted(At)?;
|
||||
let doc = pop_doc_comment(&mut items, eol_since_last_comment);
|
||||
@ -449,22 +450,10 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_import(&mut self, attributes: AttributeSet<'src>) -> CompileResult<'src, Item<'src>> {
|
||||
self.presume_keyword(Keyword::Import)?;
|
||||
let optional = self.accepted(QuestionMark)?;
|
||||
let (path, relative) = self.parse_string_literal_token()?;
|
||||
Ok(Item::Import {
|
||||
absolute: None,
|
||||
attributes,
|
||||
optional,
|
||||
path,
|
||||
relative,
|
||||
})
|
||||
}
|
||||
/// Parse an alias, e.g `alias name := target`
|
||||
fn parse_alias(
|
||||
&mut self,
|
||||
attributes: AttributeSet<'src>,
|
||||
attributes: BTreeSet<Attribute<'src>>,
|
||||
) -> CompileResult<'src, Alias<'src, Name<'src>>> {
|
||||
self.presume_keyword(Keyword::Alias)?;
|
||||
let name = self.parse_name()?;
|
||||
@ -756,7 +745,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
&mut self,
|
||||
doc: Option<&'src str>,
|
||||
quiet: bool,
|
||||
attributes: AttributeSet<'src>,
|
||||
attributes: BTreeSet<Attribute<'src>>,
|
||||
) -> CompileResult<'src, UnresolvedRecipe<'src>> {
|
||||
let name = self.parse_name()?;
|
||||
|
||||
@ -818,7 +807,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
|
||||
Ok(Recipe {
|
||||
shebang: body.first().map_or(false, Line::is_shebang),
|
||||
attributes: attributes.to_btree_set(),
|
||||
attributes,
|
||||
body,
|
||||
dependencies,
|
||||
doc,
|
||||
@ -995,7 +984,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
}
|
||||
|
||||
/// Parse recipe attributes
|
||||
fn parse_attributes(&mut self) -> CompileResult<'src, Option<AttributeSet<'src>>> {
|
||||
fn parse_attributes(&mut self) -> CompileResult<'src, Option<BTreeSet<Attribute<'src>>>> {
|
||||
let mut attributes = BTreeMap::new();
|
||||
|
||||
while self.accepted(BracketL)? {
|
||||
@ -1035,7 +1024,7 @@ impl<'run, 'src> Parser<'run, 'src> {
|
||||
if attributes.is_empty() {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(AttributeSet::from_map(attributes)))
|
||||
Ok(Some(attributes.into_keys().collect()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ fn error_from_signal(recipe: &str, line_number: Option<usize>, exit_status: Exit
|
||||
/// A recipe, e.g. `foo: bar baz`
|
||||
#[derive(PartialEq, Debug, Clone, Serialize)]
|
||||
pub(crate) struct Recipe<'src, D = Dependency<'src>> {
|
||||
//TODO make this be attributeset too
|
||||
pub(crate) attributes: BTreeSet<Attribute<'src>>,
|
||||
pub(crate) body: Vec<Line<'src>>,
|
||||
pub(crate) dependencies: Vec<D>,
|
||||
|
@ -8,9 +8,8 @@ pub(crate) struct RecipeResolver<'src: 'run, 'run> {
|
||||
|
||||
impl<'src: 'run, 'run> RecipeResolver<'src, 'run> {
|
||||
pub(crate) fn resolve_recipes(
|
||||
assignments: &'run Table<'src, Assignment<'src>>,
|
||||
settings: &Settings,
|
||||
unresolved_recipes: Table<'src, UnresolvedRecipe<'src>>,
|
||||
assignments: &'run Table<'src, Assignment<'src>>,
|
||||
) -> CompileResult<'src, Table<'src, Rc<Recipe<'src>>>> {
|
||||
let mut resolver = Self {
|
||||
resolved_recipes: Table::new(),
|
||||
@ -40,10 +39,6 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> {
|
||||
}
|
||||
|
||||
for line in &recipe.body {
|
||||
if line.is_comment() && settings.ignore_comments {
|
||||
continue;
|
||||
}
|
||||
|
||||
for fragment in &line.fragments {
|
||||
if let Fragment::Interpolation { expression, .. } = fragment {
|
||||
for variable in expression.variables() {
|
||||
|
12
src/run.rs
12
src/run.rs
@ -1,8 +1,8 @@
|
||||
use super::*;
|
||||
|
||||
/// Main entry point into `just`. Parse arguments from `args` and run.
|
||||
/// Main entry point into just binary.
|
||||
#[allow(clippy::missing_errors_doc)]
|
||||
pub fn run(args: impl Iterator<Item = impl Into<OsString> + Clone>) -> Result<(), i32> {
|
||||
pub fn run() -> Result<(), i32> {
|
||||
#[cfg(windows)]
|
||||
ansi_term::enable_ansi_support().ok();
|
||||
|
||||
@ -11,16 +11,12 @@ pub fn run(args: impl Iterator<Item = impl Into<OsString> + Clone>) -> Result<()
|
||||
.filter("JUST_LOG")
|
||||
.write_style("JUST_LOG_STYLE"),
|
||||
)
|
||||
.try_init()
|
||||
.ok();
|
||||
.init();
|
||||
|
||||
let app = Config::app();
|
||||
|
||||
info!("Parsing command line arguments…");
|
||||
let matches = app.try_get_matches_from(args).map_err(|err| {
|
||||
err.print().ok();
|
||||
err.exit_code()
|
||||
})?;
|
||||
let matches = app.get_matches();
|
||||
|
||||
let config = Config::from_matches(&matches).map_err(Error::from);
|
||||
|
||||
|
@ -185,13 +185,7 @@ fn status_error() {
|
||||
"exit-2": "#!/usr/bin/env bash\nexit 2\n",
|
||||
};
|
||||
|
||||
let output = Command::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(tmp.path().join("exit-2"))
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
assert!(output.status.success());
|
||||
("chmod", "+x", tmp.path().join("exit-2")).run();
|
||||
|
||||
let path = env::join_paths(
|
||||
iter::once(tmp.path().to_owned()).chain(env::split_paths(&env::var_os("PATH").unwrap())),
|
||||
|
@ -1,27 +0,0 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn datetime() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
x := datetime('%Y-%m-%d %z')
|
||||
",
|
||||
)
|
||||
.args(["--eval", "x"])
|
||||
.stdout_regex(r"\d\d\d\d-\d\d-\d\d [+-]\d\d\d\d")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn datetime_utc() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
x := datetime_utc('%Y-%m-%d %Z')
|
||||
",
|
||||
)
|
||||
.args(["--eval", "x"])
|
||||
.stdout_regex(r"\d\d\d\d-\d\d-\d\d UTC")
|
||||
.run();
|
||||
}
|
@ -64,13 +64,7 @@ fn status_error() {
|
||||
"exit-2": "#!/usr/bin/env bash\nexit 2\n",
|
||||
};
|
||||
|
||||
let output = Command::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(tmp.path().join("exit-2"))
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
assert!(output.status.success());
|
||||
("chmod", "+x", tmp.path().join("exit-2")).run();
|
||||
|
||||
let path = env::join_paths(
|
||||
iter::once(tmp.path().to_owned()).chain(env::split_paths(&env::var_os("PATH").unwrap())),
|
||||
|
@ -126,13 +126,7 @@ fn write_error() {
|
||||
|
||||
let justfile_path = test.justfile_path();
|
||||
|
||||
let output = Command::new("chmod")
|
||||
.arg("400")
|
||||
.arg(&justfile_path)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
assert!(output.status.success());
|
||||
("chmod", "400", &justfile_path).run();
|
||||
|
||||
let _tempdir = test.run();
|
||||
|
||||
|
@ -97,41 +97,3 @@ fn dont_evaluate_comments() {
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_analyze_comments() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set ignore-comments
|
||||
|
||||
some_recipe:
|
||||
# {{ bar }}
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn comments_still_must_be_parsable_when_ignored() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
set ignore-comments
|
||||
|
||||
some_recipe:
|
||||
# {{ foo bar }}
|
||||
",
|
||||
)
|
||||
.stderr(
|
||||
"
|
||||
error: Expected '}}', '(', '+', or '/', but found identifier
|
||||
——▶ justfile:4:12
|
||||
│
|
||||
4 │ # {{ foo bar }}
|
||||
│ ^^^
|
||||
",
|
||||
)
|
||||
.status(EXIT_FAILURE)
|
||||
.run();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ pub(crate) use {
|
||||
tempdir::tempdir,
|
||||
test::{assert_eval_eq, Output, Test},
|
||||
},
|
||||
cradle::input::Input,
|
||||
executable_path::executable_path,
|
||||
just::unindent,
|
||||
libc::{EXIT_FAILURE, EXIT_SUCCESS},
|
||||
@ -46,7 +47,6 @@ mod completions;
|
||||
mod conditional;
|
||||
mod confirm;
|
||||
mod constants;
|
||||
mod datetime;
|
||||
mod delimiters;
|
||||
mod directories;
|
||||
mod dotenv;
|
||||
|
Loading…
Reference in New Issue
Block a user