mirror of
https://github.com/nushell/nushell
synced 2025-01-28 04:45:18 +00:00
Communicate better. update -> permit. Thanks @jonathandturner
This commit is contained in:
parent
0231e64e37
commit
c5568b426c
1 changed files with 17 additions and 10 deletions
|
@ -41,10 +41,8 @@ impl Str {
|
||||||
self.field = Some(field);
|
self.field = Some(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self) {
|
fn permit(&mut self) -> bool {
|
||||||
if self.action.is_some() {
|
self.action.is_none()
|
||||||
self.log_error("can only apply one");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log_error(&mut self, message: &str) {
|
fn log_error(&mut self, message: &str) {
|
||||||
|
@ -52,18 +50,27 @@ impl Str {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_to_int(&mut self) {
|
fn for_to_int(&mut self) {
|
||||||
self.update();
|
if self.permit() {
|
||||||
self.action = Some(Action::ToInteger);
|
self.action = Some(Action::ToInteger);
|
||||||
|
} else {
|
||||||
|
self.log_error("can only apply one");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_downcase(&mut self) {
|
fn for_downcase(&mut self) {
|
||||||
self.update();
|
if self.permit() {
|
||||||
self.action = Some(Action::Downcase);
|
self.action = Some(Action::Downcase);
|
||||||
|
} else {
|
||||||
|
self.log_error("can only apply one");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_upcase(&mut self) {
|
fn for_upcase(&mut self) {
|
||||||
self.update();
|
if self.permit() {
|
||||||
self.action = Some(Action::Upcase);
|
self.action = Some(Action::Upcase);
|
||||||
|
} else {
|
||||||
|
self.log_error("can only apply one");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &'static str {
|
fn usage(&self) -> &'static str {
|
||||||
|
|
Loading…
Reference in a new issue