mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 23:22:32 +02:00
Deprecate --flag: bool
in custom command (#11365)
# Description While #11057 is merged, it's hard to tell the difference between `--flag: bool` and `--flag`, and it makes user hard to read custom commands' signature, and hard to use them correctly. After discussion, I think we can deprecate `--flag: bool` usage, and encourage using `--flag` instead. # User-Facing Changes The following code will raise warning message, but don't stop from running. ```nushell ❯ def florb [--dry-run: bool, --another-flag] { "aaa" }; florb Error: × Deprecated: --flag: bool ╭─[entry #7:1:1] 1 │ def florb [--dry-run: bool, --another-flag] { "aaa" }; florb · ──┬─ · ╰── `--flag: bool` is deprecated. Please use `--flag` instead, more info: https://www.nushell.sh/book/custom_commands.html ╰──── aaa ``` cc @kubouch # Tests + Formatting Done # After Submitting - [ ] Add more information under https://www.nushell.sh/book/custom_commands.html to indicate `--dry-run: bool` is not allowed, - [ ] remove `: bool` from custom commands between 0.89 and 0.90 --------- Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
This commit is contained in:
@ -6,7 +6,7 @@ use crate::ast::Block;
|
||||
use crate::{
|
||||
BlockId, Config, DeclId, FileId, Module, ModuleId, Span, Type, VarId, Variable, VirtualPathId,
|
||||
};
|
||||
use crate::{Category, ParseError, Value};
|
||||
use crate::{Category, ParseError, ParseWarning, Value};
|
||||
use core::panic;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::PathBuf;
|
||||
@ -27,6 +27,7 @@ pub struct StateWorkingSet<'a> {
|
||||
/// Whether or not predeclarations are searched when looking up a command (used with aliases)
|
||||
pub search_predecls: bool,
|
||||
pub parse_errors: Vec<ParseError>,
|
||||
pub parse_warnings: Vec<ParseWarning>,
|
||||
}
|
||||
|
||||
impl<'a> StateWorkingSet<'a> {
|
||||
@ -39,6 +40,7 @@ impl<'a> StateWorkingSet<'a> {
|
||||
parsed_module_files: vec![],
|
||||
search_predecls: true,
|
||||
parse_errors: vec![],
|
||||
parse_warnings: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,6 +52,10 @@ impl<'a> StateWorkingSet<'a> {
|
||||
self.parse_errors.push(parse_error)
|
||||
}
|
||||
|
||||
pub fn warning(&mut self, parse_warning: ParseWarning) {
|
||||
self.parse_warnings.push(parse_warning)
|
||||
}
|
||||
|
||||
pub fn num_files(&self) -> usize {
|
||||
self.delta.num_files() + self.permanent_state.num_files()
|
||||
}
|
||||
|
Reference in New Issue
Block a user