Skip to main content

just/
lib.rs

1//! `just` is primarily used as a command-line binary, but does provide a
2//! limited public library interface.
3//!
4//! Please keep in mind that there are no semantic version guarantees for the
5//! library interface. It may break or change at any time.
6
7pub(crate) use {
8  crate::{
9    alias::Alias,
10    alias_style::AliasStyle,
11    analyzer::Analyzer,
12    arg_attribute::ArgAttribute,
13    assignment::Assignment,
14    ast::Ast,
15    attribute::{Attribute, AttributeKind},
16    attribute_set::AttributeSet,
17    binding::Binding,
18    cache::Cache,
19    cache_entry::CacheEntry,
20    cache_key::CacheKey,
21    cache_lock::CacheLock,
22    cache_status::CacheStatus,
23    clean::Clean,
24    color::Color,
25    color_display::ColorDisplay,
26    command_color::CommandColor,
27    command_ext::CommandExt,
28    compilation::Compilation,
29    compile_error::CompileError,
30    compile_error_kind::CompileErrorKind,
31    compiler::Compiler,
32    completer::Completer,
33    conditional_operator::ConditionalOperator,
34    config::Config,
35    config_error::ConfigError,
36    const_error::ConstError,
37    const_eval_error::ConstEvalError,
38    constants::constants,
39    count::Count,
40    datetime_format::datetime_format,
41    datetime_format_error::DatetimeFormatError,
42    delimiter::Delimiter,
43    dependency::Dependency,
44    dependency_argument::DependencyArgument,
45    disabled::Disabled,
46    dump_format::DumpFormat,
47    element::Element,
48    enclosure::Enclosure,
49    environment::Environment,
50    error::Error,
51    evaluate_format::EvaluateFormat,
52    evaluator::Evaluator,
53    execution_context::ExecutionContext,
54    executor::Executor,
55    expression::Expression,
56    expression_context::ExpressionContext,
57    format_string_part::FormatStringPart,
58    fragment::Fragment,
59    function::Function,
60    function_definition::FunctionDefinition,
61    indentation::Indentation,
62    interpreter::Interpreter,
63    invocation::Invocation,
64    invocation_parser::InvocationParser,
65    item::{Item, ItemKind},
66    justfile::Justfile,
67    keyed::Keyed,
68    keyword::Keyword,
69    layer::Layer,
70    lexer::Lexer,
71    line::Line,
72    list::List,
73    list_entry::ListEntry,
74    list_feature::ListFeature,
75    list_operator::ListOperator,
76    load_dotenv::load_dotenv,
77    loader::Loader,
78    modulepath::Modulepath,
79    name::Name,
80    namepath::Namepath,
81    number::Number,
82    numerator::Numerator,
83    ordinal::Ordinal,
84    output_error::OutputError,
85    parameter::Parameter,
86    parameter_kind::ParameterKind,
87    parser::Parser,
88    pattern::Pattern,
89    platform::Platform,
90    platform_interface::PlatformInterface,
91    position::Position,
92    positional::Positional,
93    ran::Ran,
94    range_ext::RangeExt,
95    recipe::Recipe,
96    recipe_resolver::RecipeResolver,
97    recipe_signature::RecipeSignature,
98    reference::Reference,
99    references::References,
100    request::Request,
101    resolution::Resolution,
102    scope::Scope,
103    search::Search,
104    search_config::SearchConfig,
105    search_error::SearchError,
106    semaphore::Semaphore,
107    set::Set,
108    setting::Setting,
109    settings::Settings,
110    shebang::Shebang,
111    shell::Shell,
112    shell_kind::ShellKind,
113    show_whitespace::ShowWhitespace,
114    sigil::Sigil,
115    signal::Signal,
116    signal_handler::SignalHandler,
117    source::Source,
118    string_context::StringContext,
119    string_delimiter::StringDelimiter,
120    string_kind::StringKind,
121    string_literal::StringLiteral,
122    string_state::StringState,
123    style::Style,
124    subcommand::Subcommand,
125    suggestion::Suggestion,
126    switch::Switch,
127    table::Table,
128    tangle::tangle,
129    token::Token,
130    token_kind::TokenKind,
131    unresolved_dependency::UnresolvedDependency,
132    unresolved_recipe::UnresolvedRecipe,
133    unstable_feature::UnstableFeature,
134    usage::Usage,
135    use_color::UseColor,
136    value::Value,
137    variable_resolver::VariableResolver,
138    verbosity::Verbosity,
139    version::Version,
140    warning::Warning,
141    which::which,
142  },
143  camino::Utf8Path,
144  chrono::{DateTime, Local, TimeZone, Utc, format::StrftimeItems},
145  clap::{CommandFactory, FromArgMatches, Parser as _, ValueEnum},
146  clap_complete::{ArgValueCompleter, CompletionCandidate, PathCompleter, engine::ValueCompleter},
147  digest_io::HashWriter,
148  libc::EXIT_FAILURE,
149  rand::seq::IndexedRandom,
150  regex::Regex,
151  serde::{
152    Deserialize, Deserializer, Serialize, Serializer,
153    ser::{SerializeMap, SerializeSeq, SerializeStruct},
154  },
155  sha2::{Digest, Sha256},
156  snafu::{ResultExt, Snafu},
157  std::{
158    borrow::Borrow,
159    cmp::Ordering,
160    collections::{BTreeMap, BTreeSet, HashMap, HashSet, btree_map},
161    env::{self, VarError},
162    ffi::{OsStr, OsString},
163    fmt::{self, Debug, Display, Formatter},
164    fs::{self, File},
165    io::{self, Sink, Write},
166    iter::{self, FromIterator},
167    mem,
168    num::{NonZeroU64, ParseIntError},
169    ops::Deref,
170    ops::{Index, RangeInclusive},
171    path::{self, Component, Path, PathBuf},
172    process::{self, Command, ExitStatus, Stdio},
173    slice,
174    str::{self, Chars, FromStr},
175    sync::{Arc, Condvar, LazyLock, Mutex, MutexGuard},
176    thread,
177    time::Instant,
178    vec,
179  },
180  strum::{Display, EnumDiscriminants, EnumIter, EnumString, IntoStaticStr},
181  tempfile::TempDir,
182  typed_arena::Arena,
183  unicode_width::{UnicodeWidthChar, UnicodeWidthStr},
184};
185
186#[cfg(test)]
187pub(crate) use {
188  crate::{node::Node, tree::Tree},
189  std::borrow::Cow,
190};
191
192pub use crate::run::run;
193
194#[doc(hidden)]
195pub use {arguments::Arguments, request::Response, subcommand::INIT_JUSTFILE, unindent::unindent};
196
197type CompileResult<'a, T = ()> = Result<T, CompileError<'a>>;
198type ConfigResult<T> = Result<T, ConfigError>;
199type RunResult<'a, T = ()> = Result<T, Error<'a>>;
200type SearchResult<T> = Result<T, SearchError>;
201type StringResult = Result<String, String>;
202type ValueResult = Result<Value, String>;
203
204type ModuleAlias<'src> = Alias<'src, Modulepath>;
205type RecipeAlias<'src> = Alias<'src, Arc<Recipe<'src>>>;
206
207const JUST_DIRECTORY: &str = "just";
208const RECURSION_LIMIT: usize = if cfg!(windows) { 48 } else { 256 };
209const TEMPDIR_PREFIX: &str = "just-";
210const VERSION: &str = env!("CARGO_PKG_VERSION");
211
212#[cfg(test)]
213#[macro_use]
214pub mod testing;
215
216#[cfg(test)]
217#[macro_use]
218pub mod tree;
219
220#[cfg(test)]
221pub mod node;
222
223#[cfg(fuzzing)]
224pub mod fuzzing;
225
226// Used for testing with the `--request` subcommand.
227#[doc(hidden)]
228pub mod request;
229
230mod alias;
231mod alias_style;
232mod analyzer;
233mod arg_attribute;
234mod arguments;
235mod assignment;
236mod ast;
237mod attribute;
238mod attribute_set;
239mod binding;
240mod cache;
241mod cache_entry;
242mod cache_key;
243mod cache_lock;
244mod cache_status;
245mod clean;
246mod color;
247mod color_display;
248mod command_color;
249mod command_ext;
250mod compilation;
251mod compile_error;
252mod compile_error_kind;
253mod compiler;
254mod completer;
255mod conditional_operator;
256mod config;
257mod config_error;
258mod const_error;
259mod const_eval_error;
260mod constants;
261mod count;
262mod datetime_format;
263mod datetime_format_error;
264mod delimiter;
265mod dependency;
266mod dependency_argument;
267mod disabled;
268mod dump_format;
269mod element;
270mod enclosure;
271mod environment;
272mod error;
273mod evaluate_format;
274mod evaluator;
275mod execution_context;
276mod executor;
277mod expression;
278mod expression_context;
279mod filesystem;
280mod format_string_part;
281mod fragment;
282mod function;
283mod function_definition;
284mod indentation;
285mod interpreter;
286mod invocation;
287mod invocation_parser;
288mod item;
289mod justfile;
290mod keyed;
291mod keyword;
292mod layer;
293mod lexer;
294mod line;
295mod list;
296mod list_entry;
297mod list_feature;
298mod list_operator;
299mod load_dotenv;
300mod loader;
301mod modulepath;
302mod name;
303mod namepath;
304mod number;
305mod numerator;
306mod ordinal;
307mod output_error;
308mod parameter;
309mod parameter_kind;
310mod parser;
311mod pattern;
312mod platform;
313mod platform_interface;
314mod position;
315mod positional;
316mod ran;
317mod range_ext;
318mod recipe;
319mod recipe_resolver;
320mod recipe_signature;
321mod reference;
322mod references;
323mod resolution;
324mod run;
325mod scope;
326mod search;
327mod search_config;
328mod search_error;
329mod semaphore;
330mod set;
331mod setting;
332mod settings;
333mod shebang;
334mod shell;
335mod shell_kind;
336mod show_whitespace;
337mod sigil;
338mod signal;
339mod signal_handler;
340#[cfg(unix)]
341mod signals;
342mod source;
343mod string_context;
344mod string_delimiter;
345mod string_kind;
346mod string_literal;
347mod string_state;
348mod style;
349mod subcommand;
350mod suggestion;
351mod switch;
352mod table;
353mod tangle;
354mod token;
355mod token_kind;
356mod unindent;
357mod unresolved_dependency;
358mod unresolved_recipe;
359mod unstable_feature;
360mod usage;
361mod use_color;
362mod value;
363mod variable_resolver;
364mod verbosity;
365mod version;
366mod warning;
367mod which;