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  edit_distance::edit_distance,
123  lexiclean::Lexiclean,
124  libc::EXIT_FAILURE,
125  rand::seq::IndexedRandom,
126  regex::Regex,
127  serde::{
128    Deserialize, Serialize, Serializer,
129    ser::{SerializeMap, SerializeSeq},
130  },
131  snafu::{ResultExt, Snafu},
132  std::{
133    borrow::Cow,
134    cmp::Ordering,
135    collections::{BTreeMap, BTreeSet, HashMap, HashSet},
136    env,
137    ffi::{OsStr, OsString},
138    fmt::{self, Debug, Display, Formatter},
139    fs::{self, File},
140    io::{self, Write},
141    iter::{self, FromIterator},
142    mem,
143    ops::Deref,
144    ops::{Index, RangeInclusive},
145    path::{self, Component, Path, PathBuf},
146    process::{self, Command, ExitStatus, Stdio},
147    slice,
148    str::{self, Chars, FromStr},
149    sync::{Arc, LazyLock, Mutex, MutexGuard},
150    thread,
151    time::Instant,
152    vec,
153  },
154  strum::{Display, EnumDiscriminants, EnumIter, EnumString, IntoStaticStr},
155  tempfile::TempDir,
156  typed_arena::Arena,
157  unicode_width::{UnicodeWidthChar, UnicodeWidthStr},
158};
159
160#[cfg(test)]
161pub(crate) use crate::{node::Node, tree::Tree};
162
163pub use crate::run::run;
164
165#[doc(hidden)]
166pub use {arguments::Arguments, request::Response, subcommand::INIT_JUSTFILE, unindent::unindent};
167
168type CompileResult<'a, T = ()> = Result<T, CompileError<'a>>;
169type ConfigResult<T> = Result<T, ConfigError>;
170type FunctionResult = Result<String, String>;
171type RunResult<'a, T = ()> = Result<T, Error<'a>>;
172type SearchResult<T> = Result<T, SearchError>;
173
174#[cfg(test)]
175#[macro_use]
176pub mod testing;
177
178#[cfg(test)]
179#[macro_use]
180pub mod tree;
181
182#[cfg(test)]
183pub mod node;
184
185#[cfg(fuzzing)]
186pub mod fuzzing;
187
188// Used by Janus, https://github.com/casey/janus, a tool
189// that analyses all public justfiles on GitHub to avoid
190// breaking changes.
191#[doc(hidden)]
192pub mod summary;
193
194// Used for testing with the `--request` subcommand.
195#[doc(hidden)]
196pub mod request;
197
198mod alias;
199mod alias_style;
200mod analyzer;
201mod arg_attribute;
202mod arguments;
203mod assignment;
204mod assignment_resolver;
205mod ast;
206mod attribute;
207mod attribute_set;
208mod binding;
209mod color;
210mod color_display;
211mod command_color;
212mod command_ext;
213mod compilation;
214mod compile_error;
215mod compile_error_kind;
216mod compiler;
217mod completer;
218mod condition;
219mod conditional_operator;
220mod config;
221mod config_error;
222mod const_error;
223mod constants;
224mod count;
225mod delimiter;
226mod dependency;
227mod dump_format;
228mod enclosure;
229mod error;
230mod evaluate_format;
231mod evaluator;
232mod execution_context;
233mod executor;
234mod expression;
235mod filesystem;
236mod format_string_part;
237mod fragment;
238mod function;
239mod function_definition;
240mod indentation;
241mod interpreter;
242mod invocation;
243mod invocation_parser;
244mod item;
245mod justfile;
246mod keyed;
247mod keyword;
248mod lexer;
249mod line;
250mod list;
251mod load_dotenv;
252mod loader;
253mod modulepath;
254mod name;
255mod namepath;
256mod number;
257mod numerator;
258mod ordinal;
259mod output_error;
260mod parameter;
261mod parameter_kind;
262mod parser;
263mod pattern;
264mod platform;
265mod platform_interface;
266mod position;
267mod positional;
268mod ran;
269mod range_ext;
270mod recipe;
271mod recipe_resolver;
272mod recipe_signature;
273mod reference;
274mod references;
275mod run;
276mod scope;
277mod search;
278mod search_config;
279mod search_error;
280mod set;
281mod setting;
282mod settings;
283mod shebang;
284mod shell;
285mod shell_kind;
286mod show_whitespace;
287mod sigil;
288mod signal;
289mod signal_handler;
290#[cfg(unix)]
291mod signals;
292mod source;
293mod string_delimiter;
294mod string_kind;
295mod string_literal;
296mod string_state;
297mod subcommand;
298mod suggestion;
299mod switch;
300mod table;
301mod token;
302mod token_kind;
303mod unindent;
304mod unresolved_dependency;
305mod unresolved_recipe;
306mod unstable_feature;
307mod usage;
308mod use_color;
309mod verbosity;
310mod warning;
311mod which;