Several review fixes: alias for get_file_size, duckscript tests, code tweaks

This commit is contained in:
Nikita Medvedev 2022-02-13 16:07:55 +07:00
parent 2fe17bac3e
commit 2be46d388f
No known key found for this signature in database
GPG key ID: 818D89CBE0CD5784
3 changed files with 23 additions and 4 deletions

View file

@ -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),
}
}

View file

@ -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))?;

View 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