just 1.53.0

🤖 Just a command runner
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
use super::*;

#[derive(Debug, PartialEq)]
pub(crate) struct CompileError<'src> {
  pub(crate) kind: Box<CompileErrorKind<'src>>,
  pub(crate) token: Token<'src>,
}

impl<'src> CompileError<'src> {
  pub(crate) fn context(&self) -> Token<'src> {
    self.token
  }

  pub(crate) fn new(token: Token<'src>, kind: CompileErrorKind<'src>) -> Self {
    Self {
      token,
      kind: kind.into(),
    }
  }

  pub(crate) fn source(&self) -> Option<&dyn std::error::Error> {
    match &*self.kind {
      CompileErrorKind::ArgumentPatternRegex { source } => Some(source),
      _ => None,
    }
  }
}

impl Display for CompileError<'_> {
  fn fmt(&self, f: &mut Formatter) -> fmt::Result {
    use CompileErrorKind::*;

    match &*self.kind {
      ArgAttributeRequiresOption { keyword } => {
        write!(
          f,
          "argument attribute `{keyword}` only valid with `long` or `short`"
        )
      }
      ArgumentPatternRegex { .. } => {
        write!(f, "failed to parse argument pattern")
      }
      AttributeArgumentCountMismatch {
        attribute,
        found,
        min,
        max,
      } => {
        write!(
          f,
          "attribute `{attribute}` got {} but takes ",
          Count::numbered("argument", found),
        )?;

        if min == max {
          write!(f, "{}", Count::numbered("argument", min))
        } else if found < min {
          write!(f, "at least {}", Count::numbered("argument", min))
        } else {
          write!(f, "at most {}", Count::numbered("argument", max))
        }
      }
      AttributeArgumentExpression { attribute } => {
        write!(
          f,
          "attribute `{attribute}` arguments must be string literals"
        )
      }
      AttributePositionalFollowsKeyword => {
        write!(
          f,
          "positional attribute arguments cannot follow keyword attribute arguments"
        )
      }
      BacktickShebang => write!(f, "backticks may not start with `#!`"),
      CircularRecipeDependency { recipe, circle } => {
        if circle.len() == 2 {
          write!(f, "recipe `{recipe}` depends on itself")
        } else {
          write!(
            f,
            "recipe `{recipe}` has circular dependency `{}`",
            circle.join(" -> ")
          )
        }
      }
      CircularVariableDependency { variable, circle } => {
        if circle.len() == 2 {
          write!(f, "variable `{variable}` is defined in terms of itself")
        } else {
          write!(
            f,
            "variable `{variable}` depends on its own value: `{}`",
            circle.join(" -> "),
          )
        }
      }
      DependencyArgumentCountMismatch {
        dependency,
        found,
        min,
        max,
      } => {
        write!(
          f,
          "dependency `{dependency}` got {} but takes ",
          Count::numbered("argument", found),
        )?;

        if min == max {
          write!(f, "{}", Count::numbered("argument", min))
        } else if found < min {
          write!(f, "at least {}", Count::numbered("argument", min))
        } else {
          write!(f, "at most {}", Count::numbered("argument", max))
        }
      }
      DuplicateArgAttribute { arg, first } => write!(
        f,
        "recipe attribute for argument `{arg}` first used on line {} is duplicated on line {}",
        first.ordinal(),
        self.token.line.ordinal(),
      ),
      DuplicateAttribute { attribute, first } => write!(
        f,
        "recipe attribute `{attribute}` first used on line {} is duplicated on line {}",
        first.ordinal(),
        self.token.line.ordinal(),
      ),
      DuplicateDefault { recipe } => write!(
        f,
        "recipe `{recipe}` has duplicate `[default]` attribute, which may only appear once per module",
      ),
      DuplicateOption { recipe, option } => {
        write!(
          f,
          "recipe `{recipe}` defines option `{option}` multiple times"
        )
      }
      DuplicateParameter { recipe, parameter } => {
        write!(f, "recipe `{recipe}` has duplicate parameter `{parameter}`")
      }
      DuplicateSet { setting, first } => write!(
        f,
        "setting `{setting}` first set on line {} is redefined on line {}",
        first.ordinal(),
        self.token.line.ordinal(),
      ),
      DuplicateVariable { variable } => {
        write!(f, "variable `{variable}` has multiple definitions")
      }
      DuplicateUnexport { variable } => {
        write!(f, "variable `{variable}` is unexported multiple times")
      }
      ExitMessageAndNoExitMessageAttribute { recipe } => write!(
        f,
        "recipe `{recipe}` has both `[exit-message]` and `[no-exit-message]` attributes"
      ),
      ExpectedKeyword { expected, found } => {
        let expected = List::or_ticked(expected);
        if found.kind == TokenKind::Identifier {
          write!(
            f,
            "expected keyword {expected} but found identifier `{}`",
            found.lexeme()
          )
        } else {
          write!(f, "expected keyword {expected} but found `{}`", found.kind)
        }
      }
      ExportUnexported { variable } => {
        write!(f, "variable {variable} is both exported and unexported")
      }
      ExtraLeadingWhitespace => write!(f, "recipe line has extra leading whitespace"),
      ExtraneousAttributes { count } => {
        write!(f, "extraneous {}", Count::unnumbered("attribute", count))
      }
      FlagAndValueArgAttribute { parameter } => {
        write!(
          f,
          "argument `{parameter}` may not have both `flag` and `value` attributes"
        )
      }
      FlagAttributeTakesNoValue { parameter } => {
        write!(
          f,
          "`flag` attribute for argument `{parameter}` takes no value"
        )
      }
      FlagWithDefault { parameter } => {
        write!(f, "flag parameter `{parameter}` may not have a default")
      }
      FunctionArgumentCountMismatch {
        function,
        arguments,
        expected,
      } => write!(
        f,
        "function `{function}` called with {} but takes {}",
        Count::numbered("argument", arguments),
        expected.display(),
      ),
      GuardAndInfallibleSigil => write!(
        f,
        "the guard `?` and infallible `-` sigils may not be used together"
      ),
      Include => write!(
        f,
        "the `!include` directive has been stabilized as `import`"
      ),
      InconsistentLeadingWhitespace { expected, found } => write!(
        f,
        "recipe line has inconsistent leading whitespace, started with `{}` but found line with \
          `{}`",
        ShowWhitespace(expected),
        ShowWhitespace(found)
      ),
      Internal { message } => write!(
        f,
        "internal error, this may indicate a bug in just: {message}\n\
           consider filing an issue: https://github.com/casey/just/issues/new"
      ),
      InvalidAttribute {
        item_name,
        item_kind,
        attribute,
      } => write!(
        f,
        "{item_kind} `{item_name}` has invalid attribute `{}`",
        attribute.name(),
      ),
      InvalidEscapeSequence { character } => write!(
        f,
        "`\\{}` is not a valid escape sequence",
        match character {
          '`' => "\\`".to_owned(),
          '\\' => "\\".to_owned(),
          '\'' => "'".to_owned(),
          '"' => "\"".to_owned(),
          _ => character.escape_default().collect(),
        }
      ),
      ListFeature(feature) => write!(f, "{feature}"),
      MappedDependencyMultipleStarredArguments => {
        write!(
          f,
          "mapped dependencies may not have multiple starred arguments"
        )
      }
      MappedDependencyWithoutListsSetting => {
        write!(f, "mapped dependencies require `set lists`")
      }
      MappedDependencyWithoutStarredArgument => {
        write!(f, "mapped dependencies must have starred argument")
      }
      MismatchedClosingDelimiter {
        open,
        open_line,
        close,
      } => write!(
        f,
        "mismatched closing delimiter `{}`, did you mean to close the `{}` on line {}?",
        close.close(),
        open.open(),
        open_line.ordinal(),
      ),
      MixedLeadingWhitespace { whitespace } => write!(
        f,
        "found a mix of tabs and spaces in leading whitespace: `{}`\nleading whitespace may \
           consist of tabs or spaces, but not both",
        ShowWhitespace(whitespace)
      ),
      NoCdAndWorkingDirectoryAttribute { recipe } => write!(
        f,
        "recipe `{recipe}` has both `[no-cd]` and `[working-directory]` attributes"
      ),
      NoCdAndWorkingDirectorySetting {
        first,
        first_line,
        second,
      } => write!(
        f,
        "`{}` set on line {} is incompatible with `{}`",
        first.lexeme(),
        first_line.ordinal(),
        second.lexeme()
      ),
      OptionNameContainsEqualSign { parameter } => {
        write!(
          f,
          "option name for parameter `{parameter}` contains equal sign"
        )
      }
      OptionNameEmpty { parameter } => {
        write!(f, "option name for parameter `{parameter}` is empty")
      }
      ParameterFollowsVariadicParameter { parameter } => {
        write!(f, "parameter `{parameter}` follows variadic parameter")
      }
      ParsingRecursionDepthExceeded => write!(f, "parsing recursion depth exceeded"),
      Redefinition {
        first,
        first_type,
        name,
        second_type,
      } => {
        if first_type == second_type {
          write!(
            f,
            "{first_type} `{name}` first defined on line {} is redefined on line {}",
            first.ordinal(),
            self.token.line.ordinal(),
          )
        } else {
          write!(
            f,
            "{first_type} `{name}` defined on line {} is redefined as {} {second_type} on line {}",
            first.ordinal(),
            if *second_type == "alias" { "an" } else { "a" },
            self.token.line.ordinal(),
          )
        }
      }
      ScriptAndShellAttribute { recipe } => write!(
        f,
        "recipe `{recipe}` has both `[script]` and `[shell]` attributes"
      ),
      ShellExpansion { err } => write!(f, "shell expansion failed: {err}"),
      ShortOptionWithMultipleCharacters { parameter } => {
        write!(
          f,
          "short option name for parameter `{parameter}` contains multiple characters"
        )
      }
      StarredArgumentOutsideMappedDependency => write!(
        f,
        "starred arguments may not be used outside mapped dependencies",
      ),
      RequiredParameterFollowsDefaultParameter { parameter } => write!(
        f,
        "non-default parameter `{parameter}` follows default parameter"
      ),
      UndefinedArgAttribute { argument } => {
        write!(f, "argument attribute for undefined argument `{argument}`")
      }
      UndefinedFunction { function } => write!(f, "call to undefined function `{function}`"),
      UndefinedVariable { variable } => write!(f, "variable `{variable}` not defined"),
      UnexpectedCharacter { expected } => {
        write!(f, "expected character {}", List::or_ticked(expected))
      }
      UnexpectedClosingDelimiter { close } => {
        write!(f, "unexpected closing delimiter `{}`", close.close())
      }
      UnexpectedEndOfToken { expected } => {
        write!(
          f,
          "expected character {} but found end-of-file",
          List::or_ticked(expected),
        )
      }
      UnexpectedToken { expected, found } => {
        write!(f, "expected {}, but found {found}", List::or(expected))
      }
      UnicodeEscapeCharacter { character } => {
        write!(f, "expected hex digit [0-9A-Fa-f] but found `{character}`")
      }
      UnicodeEscapeDelimiter { character } => write!(
        f,
        "expected unicode escape sequence delimiter `{{` but found `{character}`"
      ),
      UnicodeEscapeEmpty => write!(f, "unicode escape sequences must not be empty"),
      UnicodeEscapeLength { hex } => write!(
        f,
        "unicode escape sequence starting with `\\u{{{hex}` longer than six hex digits"
      ),
      UnicodeEscapeRange { hex } => {
        write!(
          f,
          "unicode escape sequence value `{hex}` greater than maximum valid code point `10FFFF`",
        )
      }
      UnicodeEscapeUnterminated => write!(f, "unterminated unicode escape sequence"),
      UnknownAliasTarget { alias, target } => {
        write!(f, "alias `{alias}` has an unknown target `{target}`")
      }
      AttributeKeyMissingValue { key } => {
        write!(f, "attribute key `{key}` requires value")
      }
      UnknownAttributeKeyword { attribute, keyword } => {
        write!(f, "unknown keyword `{keyword}` for `{attribute}` attribute")
      }
      UnknownAttribute { attribute } => write!(f, "unknown attribute `{attribute}`"),
      UnknownDependency { recipe, unknown } => {
        write!(f, "recipe `{recipe}` has unknown dependency `{unknown}`")
      }
      UnknownSetting { setting } => write!(f, "unknown setting `{setting}`"),
      UnknownStartOfToken { start } => {
        write!(f, "unknown start of token '{start}'")?;
        if !start.is_ascii_graphic() {
          write!(f, " (U+{:04X})", *start as u32)?;
        }
        Ok(())
      }
      UnpairedCarriageReturn => write!(f, "unpaired carriage return"),
      UnterminatedBacktick => write!(f, "unterminated backtick"),
      UnterminatedInterpolation => write!(f, "unterminated interpolation"),
      UnterminatedString => write!(f, "unterminated string"),
      VariadicParameterWithOption => write!(f, "variadic parameters may not be options"),
    }
  }
}