mirror of
https://github.com/sagiegurari/duckscript
synced 2024-09-05 16:23:56 +00:00
Several review fixes: alias for get_file_size, duckscript tests, code tweaks
This commit is contained in:
parent
2fe17bac3e
commit
2be46d388f
|
@ -16,7 +16,7 @@ impl Command for CommandImpl {
|
|||
}
|
||||
|
||||
fn aliases(&self) -> Vec<String> {
|
||||
vec!["get_file_size".to_string()]
|
||||
vec!["get_file_size".to_string(), "filesize".to_string()]
|
||||
}
|
||||
|
||||
fn help(&self) -> String {
|
||||
|
@ -32,7 +32,7 @@ impl Command for CommandImpl {
|
|||
CommandResult::Error("Path not provided.".to_string())
|
||||
} else {
|
||||
match io::get_file_size(&arguments[0]) {
|
||||
Ok(time) => CommandResult::Continue(Some(time.to_string())),
|
||||
Ok(size) => CommandResult::Continue(Some(size.to_string())),
|
||||
Err(error) => CommandResult::Error(error),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ mod cp;
|
|||
mod cp_glob;
|
||||
mod dirname;
|
||||
mod exists;
|
||||
mod get_last_modified_time;
|
||||
mod get_file_size;
|
||||
mod get_last_modified_time;
|
||||
mod gitignore_path_array;
|
||||
mod glob_array;
|
||||
mod is_directory;
|
||||
|
@ -46,8 +46,8 @@ pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptEr
|
|||
commands.set(cp_glob::create(&package)?)?;
|
||||
commands.set(dirname::create(&package))?;
|
||||
commands.set(exists::create(&package))?;
|
||||
commands.set(get_last_modified_time::create(&package))?;
|
||||
commands.set(get_file_size::create(&package))?;
|
||||
commands.set(get_last_modified_time::create(&package))?;
|
||||
commands.set(gitignore_path_array::create(&package))?;
|
||||
commands.set(glob_array::create(&package))?;
|
||||
commands.set(is_directory::create(&package))?;
|
||||
|
|
19
test/std/fs/get_file_size_test.ds
Normal file
19
test/std/fs/get_file_size_test.ds
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
fn test_file
|
||||
size = get_file_size ./Cargo.toml
|
||||
positive = greater_than ${size} 0
|
||||
|
||||
assert ${positive}
|
||||
end
|
||||
|
||||
fn test_directory
|
||||
size = get_file_size ./src
|
||||
|
||||
assert_false ${size}
|
||||
end
|
||||
|
||||
fn test_not_found
|
||||
size = get_file_size ./badfile
|
||||
|
||||
assert_false ${size}
|
||||
end
|
Loading…
Reference in a new issue