Skip to content

Commit

Permalink
mktemp: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tskinn committed Nov 17, 2023
1 parent 3cc057d commit 9db2efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions crates/nu-command/src/filesystem/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value,
};

use std::path::PathBuf;
Expand All @@ -17,7 +17,7 @@ impl Command for Mktemp {
}

fn usage(&self) -> &str {
"Create temporary files or directories using uutils/coreutils mktemp. TEMPLATE must contain at least 3 consecutive 'X's in last component."
"Create temporary files or directories using uutils/coreutils mktemp."
}

fn search_terms(&self) -> Vec<&str> {
Expand All @@ -34,14 +34,14 @@ impl Command for Mktemp {
fn signature(&self) -> Signature {
Signature::build("mktemp")
.input_output_types(vec![(Type::Nothing, Type::String)])
.optional(
.optional(
"template",
SyntaxShape::String,
"Optional pattern from which the name of the file or directory is derived. Must contain at least three 'X's in last component.",
)
.named("suffix", SyntaxShape::String, "Append suffix to template; must not contain a slash.", None)
.named("tmpdir-path", SyntaxShape::Filepath, "Interpret TEMPLATE relative to tmpdir-path. If tmpdir-path is not set use $TMPDIR", Some('p'))
.switch("tmpdir", "Interpret TEMPLATE relative to the system temporary directory.", Some('t'))
.switch("tmpdir", "Interpret TEMPLATE relative to the system temporary directory.", Some('t'))
.switch("directory", "Create a directory instead of a file.", Some('d'))
.category(Category::FileSystem)
}
Expand Down Expand Up @@ -111,22 +111,22 @@ impl Command for Mktemp {
Example {
description: "Make a temporary file with the given suffix in the current working directory.",
example: "mktemp --suffix .txt",
result: Some(Value::string("<WORKING_DIR>/tmp.lekjbhelyx.txt", Span::new(0, 0))),
result: Some(Value::test_string("<WORKING_DIR>/tmp.lekjbhelyx.txt")),
},
Example {
description: "Make a temporary file named testfile.XXX with the 'X's as random characters in the current working directory. If a template is provided, it must end in at least three 'X's.",
description: "Make a temporary file named testfile.XXX with the 'X's as random characters in the current working directory.",
example: "mktemp testfile.XXX",
result: Some(Value::string("<WORKING_DIR>/testfile.4kh", Span::new(0, 0))),
result: Some(Value::test_string("<WORKING_DIR>/testfile.4kh")),
},
Example {
description: "Make a temporary file with a template in the system temp directory.",
example: "mktemp -t testfile.XXX",
result: Some(Value::string("/tmp/testfile.4kh", Span::new(0, 0))),
result: Some(Value::test_string("/tmp/testfile.4kh")),
},
Example {
description: "Make a temporary directory with randomly generated name in the temporary directory.",
example: "mktemp -d",
result: Some(Value::string("/tmp/tmp.NMw9fJr8K0", Span::new(0, 0))),
result: Some(Value::test_string("/tmp/tmp.NMw9fJr8K0")),
},
]
}
Expand Down

0 comments on commit 9db2efe

Please sign in to comment.