-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add shell specific command execution
- Loading branch information
Showing
16 changed files
with
485 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,17 @@ | ||
use crate::utils::{config::AdaptiveInit, script::*}; | ||
use log::debug; | ||
use crate::utils::{ | ||
config::{ShellSpecificCommand, SupportedShellSpecificCommand}, | ||
script::*, | ||
shells::SupportedShell, | ||
}; | ||
|
||
pub fn init(adaptive_init: &AdaptiveInit) -> Result<String, Box<dyn std::error::Error>> { | ||
let init_result = match adaptive_init { | ||
AdaptiveInit::Run(cmd) => run_cmd_with_output(&cmd)?, | ||
AdaptiveInit::OSSpecific { | ||
linux, | ||
macos, | ||
windows, | ||
} => { | ||
let os = std::env::consts::OS; | ||
match os { | ||
"linux" => { | ||
if let Some(cmd) = &linux { | ||
run_cmd_with_output(&cmd)? | ||
} else { | ||
"".to_owned() | ||
} | ||
} | ||
"macos" => { | ||
if let Some(cmd) = &macos { | ||
run_cmd_with_output(&cmd)? | ||
} else { | ||
"".to_owned() | ||
} | ||
} | ||
"windows" => { | ||
if let Some(cmd) = &windows { | ||
run_cmd_with_output(&cmd)? | ||
} else { | ||
"".to_owned() | ||
} | ||
} | ||
_ => { | ||
debug!("init hook: unsupported os os={}", os); | ||
"".to_owned() | ||
} | ||
} | ||
pub fn init( | ||
current_shell: &SupportedShell, | ||
init_cmd: &ShellSpecificCommand, | ||
) -> Result<String, Box<dyn std::error::Error>> { | ||
match init_cmd { | ||
ShellSpecificCommand::Generic(generic) => run_cmd_with_output(current_shell, generic), | ||
ShellSpecificCommand::ShellSpecific(shell_specific) => { | ||
run_shell_cmd(current_shell, shell_specific) | ||
} | ||
}; | ||
|
||
Ok(init_result) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,13 @@ | ||
use crate::utils::{config::AdaptiveInstall, script::*}; | ||
use crate::utils::{config::ShellSpecificCommand, script::*, shells::SupportedShell}; | ||
|
||
pub fn install(adaptive_install: &AdaptiveInstall) -> Result<(), Box<dyn std::error::Error>> { | ||
match adaptive_install { | ||
AdaptiveInstall::Run(cmd) => { | ||
run_cmd_with_output(&cmd)?; | ||
pub fn install( | ||
current_shell: &SupportedShell, | ||
install_cmd: &ShellSpecificCommand, | ||
) -> Result<String, Box<dyn std::error::Error>> { | ||
match install_cmd { | ||
ShellSpecificCommand::Generic(generic) => run_cmd_with_output(current_shell, generic), | ||
ShellSpecificCommand::ShellSpecific(shell_specific) => { | ||
run_shell_cmd(current_shell, shell_specific) | ||
} | ||
AdaptiveInstall::OSSpecific { | ||
linux, | ||
macos, | ||
windows, | ||
} => { | ||
let os = std::env::consts::OS; | ||
match os { | ||
"linux" => { | ||
if let Some(cmd) = &linux { | ||
run_cmd(&cmd)?; | ||
} | ||
} | ||
"macos" => { | ||
if let Some(cmd) = &macos { | ||
run_cmd(&cmd)?; | ||
} | ||
} | ||
"windows" => { | ||
if let Some(cmd) = &windows { | ||
run_cmd(&cmd)?; | ||
} | ||
} | ||
_ => { | ||
println!("install hook: unsupported os os={}", os); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
use crate::utils::{config::ShellSpecificCommand, script::*, shells::SupportedShell}; | ||
|
||
pub fn load( | ||
current_shell: &SupportedShell, | ||
load_cmd: &ShellSpecificCommand, | ||
) -> Result<String, Box<dyn std::error::Error>> { | ||
match load_cmd { | ||
ShellSpecificCommand::Generic(generic) => run_cmd_with_output(current_shell, generic), | ||
ShellSpecificCommand::ShellSpecific(shell_specific) => { | ||
run_shell_cmd(current_shell, shell_specific) | ||
} | ||
} | ||
} |
Oops, something went wrong.