mirror of
https://github.com/casey/just.git
synced 2024-11-26 11:43:43 +03:00
Don't load .env
file when --no-dotenv
is passed (#627)
Add a `--no-dotenv` flag that suppresses loading `.env` files.
This commit is contained in:
parent
fef69a3ec1
commit
d6a1a2b568
@ -20,7 +20,7 @@ _just() {
|
|||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
just)
|
just)
|
||||||
opts=" -q -v -e -l -h -V -f -d -s --dry-run --highlight --no-highlight --quiet --clear-shell-args --verbose --dump --edit --evaluate --init --list --summary --variables --help --version --color --justfile --set --shell --shell-arg --working-directory --completions --show <ARGUMENTS>... "
|
opts=" -q -v -e -l -h -V -f -d -s --dry-run --highlight --no-dotenv --no-highlight --quiet --clear-shell-args --verbose --dump --edit --evaluate --init --list --summary --variables --help --version --color --justfile --set --shell --shell-arg --working-directory --completions --show <ARGUMENTS>... "
|
||||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
|
@ -27,6 +27,7 @@ edit:completion:arg-completer[just] = [@words]{
|
|||||||
cand --show 'Show information about <RECIPE>'
|
cand --show 'Show information about <RECIPE>'
|
||||||
cand --dry-run 'Print what just would do without doing it'
|
cand --dry-run 'Print what just would do without doing it'
|
||||||
cand --highlight 'Highlight echoed recipe lines in bold'
|
cand --highlight 'Highlight echoed recipe lines in bold'
|
||||||
|
cand --no-dotenv 'Don''t load `.env` file'
|
||||||
cand --no-highlight 'Don''t highlight echoed recipe lines in bold'
|
cand --no-highlight 'Don''t highlight echoed recipe lines in bold'
|
||||||
cand -q 'Suppress all output'
|
cand -q 'Suppress all output'
|
||||||
cand --quiet 'Suppress all output'
|
cand --quiet 'Suppress all output'
|
||||||
|
@ -19,6 +19,7 @@ complete -c just -n "__fish_use_subcommand" -l completions -d 'Print shell compl
|
|||||||
complete -c just -n "__fish_use_subcommand" -s s -l show -d 'Show information about <RECIPE>'
|
complete -c just -n "__fish_use_subcommand" -s s -l show -d 'Show information about <RECIPE>'
|
||||||
complete -c just -n "__fish_use_subcommand" -l dry-run -d 'Print what just would do without doing it'
|
complete -c just -n "__fish_use_subcommand" -l dry-run -d 'Print what just would do without doing it'
|
||||||
complete -c just -n "__fish_use_subcommand" -l highlight -d 'Highlight echoed recipe lines in bold'
|
complete -c just -n "__fish_use_subcommand" -l highlight -d 'Highlight echoed recipe lines in bold'
|
||||||
|
complete -c just -n "__fish_use_subcommand" -l no-dotenv -d 'Don\'t load `.env` file'
|
||||||
complete -c just -n "__fish_use_subcommand" -l no-highlight -d 'Don\'t highlight echoed recipe lines in bold'
|
complete -c just -n "__fish_use_subcommand" -l no-highlight -d 'Don\'t highlight echoed recipe lines in bold'
|
||||||
complete -c just -n "__fish_use_subcommand" -s q -l quiet -d 'Suppress all output'
|
complete -c just -n "__fish_use_subcommand" -s q -l quiet -d 'Suppress all output'
|
||||||
complete -c just -n "__fish_use_subcommand" -l clear-shell-args -d 'Clear shell arguments'
|
complete -c just -n "__fish_use_subcommand" -l clear-shell-args -d 'Clear shell arguments'
|
||||||
|
@ -32,6 +32,7 @@ Register-ArgumentCompleter -Native -CommandName 'just' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--show', 'show', [CompletionResultType]::ParameterName, 'Show information about <RECIPE>')
|
[CompletionResult]::new('--show', 'show', [CompletionResultType]::ParameterName, 'Show information about <RECIPE>')
|
||||||
[CompletionResult]::new('--dry-run', 'dry-run', [CompletionResultType]::ParameterName, 'Print what just would do without doing it')
|
[CompletionResult]::new('--dry-run', 'dry-run', [CompletionResultType]::ParameterName, 'Print what just would do without doing it')
|
||||||
[CompletionResult]::new('--highlight', 'highlight', [CompletionResultType]::ParameterName, 'Highlight echoed recipe lines in bold')
|
[CompletionResult]::new('--highlight', 'highlight', [CompletionResultType]::ParameterName, 'Highlight echoed recipe lines in bold')
|
||||||
|
[CompletionResult]::new('--no-dotenv', 'no-dotenv', [CompletionResultType]::ParameterName, 'Don''t load `.env` file')
|
||||||
[CompletionResult]::new('--no-highlight', 'no-highlight', [CompletionResultType]::ParameterName, 'Don''t highlight echoed recipe lines in bold')
|
[CompletionResult]::new('--no-highlight', 'no-highlight', [CompletionResultType]::ParameterName, 'Don''t highlight echoed recipe lines in bold')
|
||||||
[CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Suppress all output')
|
[CompletionResult]::new('-q', 'q', [CompletionResultType]::ParameterName, 'Suppress all output')
|
||||||
[CompletionResult]::new('--quiet', 'quiet', [CompletionResultType]::ParameterName, 'Suppress all output')
|
[CompletionResult]::new('--quiet', 'quiet', [CompletionResultType]::ParameterName, 'Suppress all output')
|
||||||
|
@ -28,6 +28,7 @@ _just() {
|
|||||||
'--show=[Show information about <RECIPE>]: :_just_commands' \
|
'--show=[Show information about <RECIPE>]: :_just_commands' \
|
||||||
'(-q --quiet)--dry-run[Print what just would do without doing it]' \
|
'(-q --quiet)--dry-run[Print what just would do without doing it]' \
|
||||||
'--highlight[Highlight echoed recipe lines in bold]' \
|
'--highlight[Highlight echoed recipe lines in bold]' \
|
||||||
|
'--no-dotenv[Don'\''t load `.env` file]' \
|
||||||
'--no-highlight[Don'\''t highlight echoed recipe lines in bold]' \
|
'--no-highlight[Don'\''t highlight echoed recipe lines in bold]' \
|
||||||
'(--dry-run)-q[Suppress all output]' \
|
'(--dry-run)-q[Suppress all output]' \
|
||||||
'(--dry-run)--quiet[Suppress all output]' \
|
'(--dry-run)--quiet[Suppress all output]' \
|
||||||
|
@ -13,6 +13,7 @@ pub(crate) struct Config {
|
|||||||
pub(crate) dry_run: bool,
|
pub(crate) dry_run: bool,
|
||||||
pub(crate) highlight: bool,
|
pub(crate) highlight: bool,
|
||||||
pub(crate) invocation_directory: PathBuf,
|
pub(crate) invocation_directory: PathBuf,
|
||||||
|
pub(crate) load_dotenv: bool,
|
||||||
pub(crate) quiet: bool,
|
pub(crate) quiet: bool,
|
||||||
pub(crate) search_config: SearchConfig,
|
pub(crate) search_config: SearchConfig,
|
||||||
pub(crate) shell: String,
|
pub(crate) shell: String,
|
||||||
@ -64,6 +65,7 @@ mod arg {
|
|||||||
pub(crate) const DRY_RUN: &str = "DRY-RUN";
|
pub(crate) const DRY_RUN: &str = "DRY-RUN";
|
||||||
pub(crate) const HIGHLIGHT: &str = "HIGHLIGHT";
|
pub(crate) const HIGHLIGHT: &str = "HIGHLIGHT";
|
||||||
pub(crate) const JUSTFILE: &str = "JUSTFILE";
|
pub(crate) const JUSTFILE: &str = "JUSTFILE";
|
||||||
|
pub(crate) const NO_DOTENV: &str = "NO-DOTENV";
|
||||||
pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT";
|
pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT";
|
||||||
pub(crate) const QUIET: &str = "QUIET";
|
pub(crate) const QUIET: &str = "QUIET";
|
||||||
pub(crate) const SET: &str = "SET";
|
pub(crate) const SET: &str = "SET";
|
||||||
@ -105,6 +107,11 @@ impl Config {
|
|||||||
.help("Highlight echoed recipe lines in bold")
|
.help("Highlight echoed recipe lines in bold")
|
||||||
.overrides_with(arg::NO_HIGHLIGHT),
|
.overrides_with(arg::NO_HIGHLIGHT),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name(arg::NO_DOTENV)
|
||||||
|
.long("no-dotenv")
|
||||||
|
.help("Don't load `.env` file"),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(arg::NO_HIGHLIGHT)
|
Arg::with_name(arg::NO_HIGHLIGHT)
|
||||||
.long("no-highlight")
|
.long("no-highlight")
|
||||||
@ -399,6 +406,7 @@ impl Config {
|
|||||||
highlight: !matches.is_present(arg::NO_HIGHLIGHT),
|
highlight: !matches.is_present(arg::NO_HIGHLIGHT),
|
||||||
quiet: matches.is_present(arg::QUIET),
|
quiet: matches.is_present(arg::QUIET),
|
||||||
shell: matches.value_of(arg::SHELL).unwrap().to_owned(),
|
shell: matches.value_of(arg::SHELL).unwrap().to_owned(),
|
||||||
|
load_dotenv: !matches.is_present(arg::NO_DOTENV),
|
||||||
color,
|
color,
|
||||||
invocation_directory,
|
invocation_directory,
|
||||||
search_config,
|
search_config,
|
||||||
@ -695,6 +703,7 @@ FLAGS:
|
|||||||
--highlight Highlight echoed recipe lines in bold
|
--highlight Highlight echoed recipe lines in bold
|
||||||
--init Initialize new justfile in project root
|
--init Initialize new justfile in project root
|
||||||
-l, --list List available recipes and their arguments
|
-l, --list List available recipes and their arguments
|
||||||
|
--no-dotenv Don't load `.env` file
|
||||||
--no-highlight Don't highlight echoed recipe lines in bold
|
--no-highlight Don't highlight echoed recipe lines in bold
|
||||||
-q, --quiet Suppress all output
|
-q, --quiet Suppress all output
|
||||||
--summary List names of available recipes
|
--summary List names of available recipes
|
||||||
|
@ -90,7 +90,11 @@ impl<'src> Justfile<'src> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let dotenv = load_dotenv()?;
|
let dotenv = if config.load_dotenv {
|
||||||
|
load_dotenv()?
|
||||||
|
} else {
|
||||||
|
BTreeMap::new()
|
||||||
|
};
|
||||||
|
|
||||||
let scope = {
|
let scope = {
|
||||||
let mut scope = Scope::new();
|
let mut scope = Scope::new();
|
||||||
|
@ -1971,6 +1971,19 @@ echo:
|
|||||||
stderr: "echo dotenv-value\necho dotenv-value\n",
|
stderr: "echo dotenv-value\necho dotenv-value\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test! {
|
||||||
|
name: no_dotenv,
|
||||||
|
justfile: "
|
||||||
|
#
|
||||||
|
X:=env_var_or_default('DOTENV_KEY', 'DEFAULT')
|
||||||
|
echo:
|
||||||
|
echo {{X}}
|
||||||
|
",
|
||||||
|
args: ("--no-dotenv"),
|
||||||
|
stdout: "DEFAULT\n",
|
||||||
|
stderr: "echo DEFAULT\n",
|
||||||
|
}
|
||||||
|
|
||||||
test! {
|
test! {
|
||||||
name: invalid_escape_sequence_message,
|
name: invalid_escape_sequence_message,
|
||||||
justfile: r#"
|
justfile: r#"
|
||||||
|
Loading…
Reference in New Issue
Block a user