Add --no-aliases to hide aliases in --list (#1961)
This commit is contained in:
parent
610aa0c52c
commit
d3d0dbef7d
@ -31,7 +31,7 @@ _just() {
|
||||
|
||||
case "${cmd}" in
|
||||
just)
|
||||
opts=" -n -q -u -v -e -l -h -V -f -d -c -s -E --check --yes --dry-run --highlight --no-deps --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --command-color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path <ARGUMENTS>... "
|
||||
opts=" -n -q -u -v -e -l -h -V -f -d -c -s -E --check --yes --dry-run --highlight --no-aliases --no-deps --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --command-color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path <ARGUMENTS>... "
|
||||
if [[ ${cur} == -* ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
|
@ -40,6 +40,7 @@ edit:completion:arg-completer[just] = [@words]{
|
||||
cand -n '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 --no-aliases 'Don''t show aliases in list'
|
||||
cand --no-deps 'Don''t run recipe dependencies'
|
||||
cand --no-dotenv 'Don''t load `.env` file'
|
||||
cand --no-highlight 'Don''t highlight echoed recipe lines in bold'
|
||||
|
@ -55,6 +55,7 @@ complete -c just -n "__fish_use_subcommand" -l check -d 'Run `--fmt` in \'check\
|
||||
complete -c just -n "__fish_use_subcommand" -l yes -d 'Automatically confirm all recipes.'
|
||||
complete -c just -n "__fish_use_subcommand" -s n -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 no-aliases -d 'Don\'t show aliases in list'
|
||||
complete -c just -n "__fish_use_subcommand" -l no-deps -d 'Don\'t run recipe dependencies'
|
||||
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'
|
||||
|
@ -45,6 +45,7 @@ Register-ArgumentCompleter -Native -CommandName 'just' -ScriptBlock {
|
||||
[CompletionResult]::new('-n', 'n', [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('--no-aliases', 'no-aliases', [CompletionResultType]::ParameterName, 'Don''t show aliases in list')
|
||||
[CompletionResult]::new('--no-deps', 'no-deps', [CompletionResultType]::ParameterName, 'Don''t run recipe dependencies')
|
||||
[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')
|
||||
|
@ -41,6 +41,7 @@ _just() {
|
||||
'(-q --quiet)-n[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]' \
|
||||
'--no-aliases[Don'\''t show aliases in list]' \
|
||||
'--no-deps[Don'\''t run recipe dependencies]' \
|
||||
'--no-dotenv[Don'\''t load `.env` file]' \
|
||||
'--no-highlight[Don'\''t highlight echoed recipe lines in bold]' \
|
||||
|
@ -31,6 +31,7 @@ pub(crate) struct Config {
|
||||
pub(crate) list_heading: String,
|
||||
pub(crate) list_prefix: String,
|
||||
pub(crate) load_dotenv: bool,
|
||||
pub(crate) no_aliases: bool,
|
||||
pub(crate) no_dependencies: bool,
|
||||
pub(crate) search_config: SearchConfig,
|
||||
pub(crate) shell: Option<String>,
|
||||
@ -103,6 +104,7 @@ mod arg {
|
||||
pub(crate) const JUSTFILE: &str = "JUSTFILE";
|
||||
pub(crate) const LIST_HEADING: &str = "LIST-HEADING";
|
||||
pub(crate) const LIST_PREFIX: &str = "LIST-PREFIX";
|
||||
pub(crate) const NO_ALIASES: &str = "NO-ALIASES";
|
||||
pub(crate) const NO_DEPS: &str = "NO-DEPS";
|
||||
pub(crate) const NO_DOTENV: &str = "NO-DOTENV";
|
||||
pub(crate) const NO_HIGHLIGHT: &str = "NO-HIGHLIGHT";
|
||||
@ -215,6 +217,11 @@ impl Config {
|
||||
.value_name("TEXT")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(arg::NO_ALIASES)
|
||||
.long("no-aliases")
|
||||
.help("Don't show aliases in list")
|
||||
)
|
||||
.arg (
|
||||
Arg::with_name(arg::NO_DEPS)
|
||||
.long("no-deps")
|
||||
@ -659,6 +666,7 @@ impl Config {
|
||||
.unwrap_or(" ")
|
||||
.to_owned(),
|
||||
load_dotenv: !matches.is_present(arg::NO_DOTENV),
|
||||
no_aliases: matches.is_present(arg::NO_ALIASES),
|
||||
no_dependencies: matches.is_present(arg::NO_DEPS),
|
||||
search_config,
|
||||
shell: matches.value_of(arg::SHELL).map(str::to_owned),
|
||||
|
@ -429,16 +429,18 @@ impl Subcommand {
|
||||
fn list(config: &Config, level: usize, justfile: &Justfile) {
|
||||
// Construct a target to alias map.
|
||||
let mut recipe_aliases: BTreeMap<&str, Vec<&str>> = BTreeMap::new();
|
||||
for alias in justfile.aliases.values() {
|
||||
if alias.is_private() {
|
||||
continue;
|
||||
}
|
||||
if !config.no_aliases {
|
||||
for alias in justfile.aliases.values() {
|
||||
if alias.is_private() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if recipe_aliases.contains_key(alias.target.name.lexeme()) {
|
||||
let aliases = recipe_aliases.get_mut(alias.target.name.lexeme()).unwrap();
|
||||
aliases.push(alias.name.lexeme());
|
||||
} else {
|
||||
recipe_aliases.insert(alias.target.name.lexeme(), vec![alias.name.lexeme()]);
|
||||
if recipe_aliases.contains_key(alias.target.name.lexeme()) {
|
||||
let aliases = recipe_aliases.get_mut(alias.target.name.lexeme()).unwrap();
|
||||
aliases.push(alias.name.lexeme());
|
||||
} else {
|
||||
recipe_aliases.insert(alias.target.name.lexeme(), vec![alias.name.lexeme()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ mod misc;
|
||||
mod modules;
|
||||
mod multibyte_char;
|
||||
mod newline_escape;
|
||||
mod no_aliases;
|
||||
mod no_cd;
|
||||
mod no_dependencies;
|
||||
mod no_exit_message;
|
||||
|
20
tests/no_aliases.rs
Normal file
20
tests/no_aliases.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn skip_alias() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
alias t := test1
|
||||
|
||||
test1:
|
||||
@echo 'test1'
|
||||
|
||||
test2:
|
||||
@echo 'test2'
|
||||
",
|
||||
)
|
||||
.args(["--no-aliases", "--list"])
|
||||
.stdout("Available recipes:\n test1\n test2\n")
|
||||
.run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user