New is_windows command

This commit is contained in:
sagie gur ari 2020-03-07 19:10:05 +00:00
parent 01f004b721
commit 39fd472bdf
10 changed files with 59 additions and 8 deletions

View file

@ -2,6 +2,7 @@
### v0.2.2
* New is_windows command.
* New glob_chmod command.
* New glob_array command #90
* New chmod command #19

View file

@ -0,0 +1,19 @@
```sh
var = is_windows
```
Returns true if the current OS family is windows.
#### Parameters
None
#### Return Value
True if the current OS family is windows.
#### Examples
```sh
windows = is_windows
```

View file

@ -0,0 +1,22 @@
use crate::types::command::create_alias_command;
use crate::utils::pckg;
use duckscript::types::command::Command;
use duckscript::types::error::ScriptError;
#[cfg(test)]
#[path = "./mod_test.rs"]
mod mod_test;
pub(crate) fn create(package: &str) -> Result<Box<dyn Command>, ScriptError> {
let name = pckg::concat(package, "IsWindows");
let command = create_alias_command(
name,
vec!["is_windows".to_string()],
include_str!("help.md").to_string(),
"is_windows".to_string(),
include_str!("script.ds").to_string(),
0,
)?;
Ok(Box::new(command))
}

View file

@ -0,0 +1,7 @@
use super::*;
use crate::test;
#[test]
fn common_functions() {
test::test_common_command_functions(create("").unwrap());
}

View file

@ -0,0 +1,3 @@
scope::is_windows::os = os_family
equals ${scope::is_windows::os} windows

View file

@ -1,6 +1,7 @@
mod get;
mod get_home_dir;
mod get_user_name;
mod is_windows;
mod os_family;
mod print_current_directory;
mod set;
@ -19,6 +20,7 @@ pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptEr
commands.set(get::create(&package))?;
commands.set(get_home_dir::create(&package))?;
commands.set(get_user_name::create(PACKAGE))?;
commands.set(is_windows::create(PACKAGE)?)?;
commands.set(os_family::create(PACKAGE))?;
commands.set(print_current_directory::create(&package))?;
commands.set(set::create(&package))?;

View file

@ -1,8 +1,8 @@
fn test_get
os = os_family
windows = is_windows
if not equals ${os} windows
if not ${windows}
directory = get_home_dir
empty = is_empty ${directory}
not_false = not equals false ${directory}

View file

@ -1,6 +1,5 @@
os = os_family
windows = equals ${os} "windows"
windows = is_windows
fn test_modify
if not ${windows}

View file

@ -1,6 +1,5 @@
os = os_family
windows = equals ${os} "windows"
windows = is_windows
fn test_modify
if not ${windows}

View file

@ -1,6 +1,5 @@
os = os_family
windows = equals ${os} "windows"
windows = is_windows
fn test_relative_path
value = dirname ./test.txt