mirror of
https://github.com/nushell/nushell.git
synced 2024-11-28 19:33:47 +01:00
Categorification: move Path commands out of the default category (#9937)
Path commands were incorrectly located in the default category... This PR moves all of the *Path* commands into their own Category called *Path*
This commit is contained in:
parent
c8f3799c20
commit
bb6335830a
@ -1,15 +1,14 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use super::PathSubcommandArguments;
|
||||||
use nu_engine::CallExt;
|
use nu_engine::CallExt;
|
||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||||
Type, Value,
|
SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
|
||||||
|
|
||||||
struct Arguments {
|
struct Arguments {
|
||||||
replace: Option<Spanned<String>>,
|
replace: Option<Spanned<String>>,
|
||||||
}
|
}
|
||||||
@ -39,6 +38,7 @@ impl Command for SubCommand {
|
|||||||
"Return original path with basename replaced by this string",
|
"Return original path with basename replaced by this string",
|
||||||
Some('r'),
|
Some('r'),
|
||||||
)
|
)
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -4,8 +4,8 @@ use nu_engine::CallExt;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||||
Type, Value,
|
SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -46,6 +46,7 @@ impl Command for SubCommand {
|
|||||||
"Number of directories to walk up",
|
"Number of directories to walk up",
|
||||||
Some('n'),
|
Some('n'),
|
||||||
)
|
)
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -5,7 +5,7 @@ use nu_path::expand_path_with;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -25,13 +25,15 @@ impl Command for SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("path exists").input_output_types(vec![
|
Signature::build("path exists")
|
||||||
(Type::String, Type::Bool),
|
.input_output_types(vec![
|
||||||
(
|
(Type::String, Type::Bool),
|
||||||
Type::List(Box::new(Type::String)),
|
(
|
||||||
Type::List(Box::new(Type::Bool)),
|
Type::List(Box::new(Type::String)),
|
||||||
),
|
Type::List(Box::new(Type::Bool)),
|
||||||
])
|
),
|
||||||
|
])
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -5,7 +5,7 @@ use nu_path::{canonicalize_with, expand_path_with};
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -41,6 +41,7 @@ impl Command for SubCommand {
|
|||||||
Some('s'),
|
Some('s'),
|
||||||
)
|
)
|
||||||
.switch("no-symlink", "Do not resolve symbolic links", Some('n'))
|
.switch("no-symlink", "Do not resolve symbolic links", Some('n'))
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -5,8 +5,8 @@ use nu_engine::CallExt;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||||
Type, Value,
|
SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -34,6 +34,7 @@ impl Command for SubCommand {
|
|||||||
(Type::Table(vec![]), Type::List(Box::new(Type::String))),
|
(Type::Table(vec![]), Type::List(Box::new(Type::String))),
|
||||||
])
|
])
|
||||||
.rest("append", SyntaxShape::String, "Path to append to the input")
|
.rest("append", SyntaxShape::String, "Path to append to the input")
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -5,8 +5,8 @@ use nu_engine::CallExt;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||||
Type, Value,
|
SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -37,6 +37,7 @@ impl Command for SubCommand {
|
|||||||
"Manually supply the extension (without the dot)",
|
"Manually supply the extension (without the dot)",
|
||||||
Some('e'),
|
Some('e'),
|
||||||
)
|
)
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -2,7 +2,7 @@ use nu_engine::get_full_help;
|
|||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
ast::Call,
|
ast::Call,
|
||||||
engine::{Command, EngineState, Stack},
|
engine::{Command, EngineState, Stack},
|
||||||
IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
|
Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -14,7 +14,9 @@ impl Command for PathCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("path").input_output_types(vec![(Type::Nothing, Type::String)])
|
Signature::build("path")
|
||||||
|
.input_output_types(vec![(Type::Nothing, Type::String)])
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -5,8 +5,8 @@ use nu_path::expand_to_real_path;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||||
Type, Value,
|
SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -39,6 +39,7 @@ impl Command for SubCommand {
|
|||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
"Parent shared with the input path",
|
"Parent shared with the input path",
|
||||||
)
|
)
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -3,7 +3,7 @@ use std::path::{Component, Path};
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -21,13 +21,15 @@ impl Command for SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("path split").input_output_types(vec![
|
Signature::build("path split")
|
||||||
(Type::String, Type::List(Box::new(Type::String))),
|
.input_output_types(vec![
|
||||||
(
|
(Type::String, Type::List(Box::new(Type::String))),
|
||||||
Type::List(Box::new(Type::String)),
|
(
|
||||||
Type::List(Box::new(Type::List(Box::new(Type::String)))),
|
Type::List(Box::new(Type::String)),
|
||||||
),
|
Type::List(Box::new(Type::List(Box::new(Type::String)))),
|
||||||
])
|
),
|
||||||
|
])
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -4,7 +4,7 @@ use nu_path::expand_tilde;
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{EngineState, Stack};
|
use nu_protocol::engine::{EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::Command, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
engine::Command, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::PathSubcommandArguments;
|
use super::PathSubcommandArguments;
|
||||||
@ -31,6 +31,7 @@ impl Command for SubCommand {
|
|||||||
),
|
),
|
||||||
])
|
])
|
||||||
.allow_variants_without_examples(true)
|
.allow_variants_without_examples(true)
|
||||||
|
.category(Category::Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -60,6 +60,7 @@ pub enum Category {
|
|||||||
Math,
|
Math,
|
||||||
Misc,
|
Misc,
|
||||||
Network,
|
Network,
|
||||||
|
Path,
|
||||||
Platform,
|
Platform,
|
||||||
Random,
|
Random,
|
||||||
Shells,
|
Shells,
|
||||||
@ -91,6 +92,7 @@ impl std::fmt::Display for Category {
|
|||||||
Category::Math => "math",
|
Category::Math => "math",
|
||||||
Category::Misc => "misc",
|
Category::Misc => "misc",
|
||||||
Category::Network => "network",
|
Category::Network => "network",
|
||||||
|
Category::Path => "path",
|
||||||
Category::Platform => "platform",
|
Category::Platform => "platform",
|
||||||
Category::Random => "random",
|
Category::Random => "random",
|
||||||
Category::Shells => "shells",
|
Category::Shells => "shells",
|
||||||
|
Loading…
Reference in New Issue
Block a user