-
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
17 changed files
with
536 additions
and
213 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug", | ||
"program": "${workspaceFolder}/target/debug/orbiter", | ||
"args": [ | ||
"init", | ||
"zsh" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
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,25 @@ | ||
use crate::utils::{config::ShellSpecificEvaluatable, shells::SupportedShell}; | ||
|
||
pub fn load( | ||
current_shell: &SupportedShell, | ||
load_cmd: &ShellSpecificEvaluatable, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
Ok(match load_cmd { | ||
ShellSpecificEvaluatable::Generic(generic) => println!("{}", generic), | ||
ShellSpecificEvaluatable::ShellSpecific(shell_specific) => { | ||
let shell_specific_evaluatable = match current_shell { | ||
SupportedShell::Sh => &shell_specific.sh, | ||
SupportedShell::Bash => &shell_specific.bash, | ||
SupportedShell::Zsh => &shell_specific.zsh, | ||
SupportedShell::Fish => &shell_specific.fish, | ||
SupportedShell::PowerShell => &shell_specific.powershell, | ||
SupportedShell::WinCmd => &shell_specific.wincmd, | ||
}; | ||
|
||
match shell_specific_evaluatable { | ||
Some(evaluatable) => println!("{}", evaluatable), | ||
None => (), | ||
} | ||
} | ||
}) | ||
} |
Oops, something went wrong.