mirror of
https://github.com/sagiegurari/duckscript
synced 2024-10-06 16:09:39 +00:00
New is_windows command
This commit is contained in:
parent
01f004b721
commit
39fd472bdf
|
@ -2,6 +2,7 @@
|
|||
|
||||
### v0.2.2
|
||||
|
||||
* New is_windows command.
|
||||
* New glob_chmod command.
|
||||
* New glob_array command #90
|
||||
* New chmod command #19
|
||||
|
|
19
duckscript_sdk/src/sdk/std/env/is_windows/help.md
vendored
Normal file
19
duckscript_sdk/src/sdk/std/env/is_windows/help.md
vendored
Normal 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
|
||||
```
|
22
duckscript_sdk/src/sdk/std/env/is_windows/mod.rs
vendored
Executable file
22
duckscript_sdk/src/sdk/std/env/is_windows/mod.rs
vendored
Executable 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))
|
||||
}
|
7
duckscript_sdk/src/sdk/std/env/is_windows/mod_test.rs
vendored
Normal file
7
duckscript_sdk/src/sdk/std/env/is_windows/mod_test.rs
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
use super::*;
|
||||
use crate::test;
|
||||
|
||||
#[test]
|
||||
fn common_functions() {
|
||||
test::test_common_command_functions(create("").unwrap());
|
||||
}
|
3
duckscript_sdk/src/sdk/std/env/is_windows/script.ds
vendored
Normal file
3
duckscript_sdk/src/sdk/std/env/is_windows/script.ds
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
scope::is_windows::os = os_family
|
||||
equals ${scope::is_windows::os} windows
|
2
duckscript_sdk/src/sdk/std/env/mod.rs
vendored
2
duckscript_sdk/src/sdk/std/env/mod.rs
vendored
|
@ -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))?;
|
||||
|
|
4
test/std/env/get_home_dir_test.ds
vendored
4
test/std/env/get_home_dir_test.ds
vendored
|
@ -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}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
os = os_family
|
||||
windows = equals ${os} "windows"
|
||||
windows = is_windows
|
||||
|
||||
fn test_modify
|
||||
if not ${windows}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
os = os_family
|
||||
windows = equals ${os} "windows"
|
||||
windows = is_windows
|
||||
|
||||
fn test_modify
|
||||
if not ${windows}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
os = os_family
|
||||
windows = equals ${os} "windows"
|
||||
windows = is_windows
|
||||
|
||||
fn test_relative_path
|
||||
value = dirname ./test.txt
|
||||
|
|
Loading…
Reference in a new issue