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    assignment_resolver::AssignmentResolver,
15    ast::Ast,
16    attribute::{Attribute, AttributeDiscriminant},
17    attribute_set::AttributeSet,
18    binding::Binding,
19    color::Color,
20    color_display::ColorDisplay,
21    command_color::CommandColor,
22    command_ext::CommandExt,
23    compilation::Compilation,
24    compile_error::CompileError,
25    compile_error_kind::CompileErrorKind,
26    compiler::Compiler,
27    completer::Completer,
28    condition::Condition,
29    conditional_operator::ConditionalOperator,
30    config::Config,
31    config_error::ConfigError,
32    const_error::ConstError,
33    constants::constants,
34    count::Count,
35    delimiter::Delimiter,
36    dependency::Dependency,
37    dump_format::DumpFormat,
38    enclosure::Enclosure,
39    error::Error,
40    evaluate_format::EvaluateFormat,
41    evaluator::Evaluator,
42    execution_context::ExecutionContext,
43    executor::Executor,
44    expression::Expression,
45    format_string_part::FormatStringPart,
46    fragment::Fragment,
47    function::Function,
48    function_definition::FunctionDefinition,
49    indentation::Indentation,
50    interpreter::Interpreter,
51    invocation::Invocation,
52    invocation_parser::InvocationParser,
53    item::Item,
54    justfile::Justfile,
55    keyed::Keyed,
56    keyword::Keyword,
57    lexer::Lexer,
58    line::Line,
59    list::List,
60    load_dotenv::load_dotenv,
61    loader::Loader,
62    modulepath::Modulepath,
63    name::Name,
64    namepath::Namepath,
65    number::Number,
66    numerator::Numerator,
67    ordinal::Ordinal,
68    output_error::OutputError,
69    parameter::Parameter,
70    parameter_kind::ParameterKind,
71    parser::Parser,
72    pattern::Pattern,
73    platform::Platform,
74    platform_interface::PlatformInterface,
75    position::Position,
76    positional::Positional,
77    ran::Ran,
78    range_ext::RangeExt,
79    recipe::Recipe,
80    recipe_resolver::RecipeResolver,
81    recipe_signature::RecipeSignature,
82    reference::Reference,
83    references::References,
84    request::Request,
85    scope::Scope,
86    search::Search,
87    search_config::SearchConfig,
88    search_error::SearchError,
89    set::Set,
90    setting::Setting,
91    settings::Settings,
92    shebang::Shebang,
93    shell::Shell,
94    shell_kind::ShellKind,
95    show_whitespace::ShowWhitespace,
96    sigil::Sigil,
97    signal::Signal,
98    signal_handler::SignalHandler,
99    source::Source,
100    string_delimiter::StringDelimiter,
101    string_kind::StringKind,
102    string_literal::StringLiteral,
103    string_state::StringState,
104    subcommand::Subcommand,
105    suggestion::Suggestion,
106    switch::Switch,
107    table::Table,
108    token::Token,
109    token_kind::TokenKind,
110    unresolved_dependency::UnresolvedDependency,
111    unresolved_recipe::UnresolvedRecipe,
112    unstable_feature::UnstableFeature,
113    usage::Usage,
114    use_color::UseColor,
115    verbosity::Verbosity,
116    warning::Warning,
117    which::which,
118  },
119  camino::Utf8Path,
120  clap::{CommandFactory, FromArgMatches, Parser as _, ValueEnum},
121  clap_complete::{ArgValueCompleter, CompletionCandidate, PathCompleter, engine::ValueCompleter},
122  lexiclean::Lexiclean,
123  libc::EXIT_FAILURE,
124  rand::seq::IndexedRandom,
125  regex::Regex,
126  serde::{
127    Deserialize, Serialize, Serializer,
128    ser::{SerializeMap, SerializeSeq},
129  },
130  snafu::{ResultExt, Snafu},
131  std::{
132    borrow::Cow,
133    cmp::Ordering,
134    collections::{BTreeMap, BTreeSet, HashMap, HashSet},
135    env,
136    ffi::{OsStr, OsString},
137    fmt::{self, Debug, Display, Formatter},
138    fs::{self, File},
139    io::{self, Write},
140    iter::{self, FromIterator},
141    mem,
142    ops::Deref,
143    ops::{Index, RangeInclusive},
144    path::{self, Component, Path, PathBuf},
145    process::{self, Command, ExitStatus, Stdio},
146    slice,
147    str::{self, Chars, FromStr},
148    sync::{Arc, LazyLock, Mutex, MutexGuard},
149    thread,
150    time::Instant,
151    vec,
152  },
153  strum::{Display, EnumDiscriminants, EnumIter, EnumString, IntoStaticStr},
154  tempfile::TempDir,
155  typed_arena::Arena,
156  unicode_width::{UnicodeWidthChar, UnicodeWidthStr},
157};
158
159#[cfg(test)]
160pub(crate) use crate::{node::Node, tree::Tree};
161
162pub use crate::run::run;
163
164#[doc(hidden)]
165pub use {arguments::Arguments, request::Response, subcommand::INIT_JUSTFILE, unindent::unindent};
166
167type CompileResult<'a, T = ()> = Result<T, CompileError<'a>>;
168type ConfigResult<T> = Result<T, ConfigError>;
169type FunctionResult = Result<String, String>;
170type RunResult<'a, T = ()> = Result<T, Error<'a>>;
171type SearchResult<T> = Result<T, SearchError>;
172
173const JUST_DIRECTORY: &str = "just";
174const RECURSION_LIMIT: usize = if cfg!(windows) { 48 } else { 256 };
175const TEMPDIR_PREFIX: &str = "just-";
176
177#[cfg(test)]
178#[macro_use]
179pub mod testing;
180
181#[cfg(test)]
182#[macro_use]
183pub mod tree;
184
185#[cfg(test)]
186pub mod node;
187
188#[cfg(fuzzing)]
189pub mod fuzzing;
190
191// Used by Janus, https://github.com/casey/janus, a tool
192// that analyses all public justfiles on GitHub to avoid
193// breaking changes.
194#[doc(hidden)]
195pub mod summary;
196
197// Used for testing with the `--request` subcommand.
198#[doc(hidden)]
199pub mod request;
200
201mod alias;
202mod alias_style;
203mod analyzer;
204mod arg_attribute;
205mod arguments;
206mod assignment;
207mod assignment_resolver;
208mod ast;
209mod attribute;
210mod attribute_set;
211mod binding;
212mod color;
213mod color_display;
214mod command_color;
215mod command_ext;
216mod compilation;
217mod compile_error;
218mod compile_error_kind;
219mod compiler;
220mod completer;
221mod condition;
222mod conditional_operator;
223mod config;
224mod config_error;
225mod const_error;
226mod constants;
227mod count;
228mod delimiter;
229mod dependency;
230mod dump_format;
231mod enclosure;
232mod error;
233mod evaluate_format;
234mod evaluator;
235mod execution_context;
236mod executor;
237mod expression;
238mod filesystem;
239mod format_string_part;
240mod fragment;
241mod function;
242mod function_definition;
243mod indentation;
244mod interpreter;
245mod invocation;
246mod invocation_parser;
247mod item;
248mod justfile;
249mod keyed;
250mod keyword;
251mod lexer;
252mod line;
253mod list;
254mod load_dotenv;
255mod loader;
256mod modulepath;
257mod name;
258mod namepath;
259mod number;
260mod numerator;
261mod ordinal;
262mod output_error;
263mod parameter;
264mod parameter_kind;
265mod parser;
266mod pattern;
267mod platform;
268mod platform_interface;
269mod position;
270mod positional;
271mod ran;
272mod range_ext;
273mod recipe;
274mod recipe_resolver;
275mod recipe_signature;
276mod reference;
277mod references;
278mod run;
279mod scope;
280mod search;
281mod search_config;
282mod search_error;
283mod set;
284mod setting;
285mod settings;
286mod shebang;
287mod shell;
288mod shell_kind;
289mod show_whitespace;
290mod sigil;
291mod signal;
292mod signal_handler;
293#[cfg(unix)]
294mod signals;
295mod source;
296mod string_delimiter;
297mod string_kind;
298mod string_literal;
299mod string_state;
300mod subcommand;
301mod suggestion;
302mod switch;
303mod table;
304mod token;
305mod token_kind;
306mod unindent;
307mod unresolved_dependency;
308mod unresolved_recipe;
309mod unstable_feature;
310mod usage;
311mod use_color;
312mod verbosity;
313mod warning;
314mod which;