-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat ENG-1019: set default provider via system tray menu
- Loading branch information
1 parent
7a72186
commit 71a63b9
Showing
13 changed files
with
157 additions
and
61 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod config; | ||
mod constants; | ||
pub mod constants; | ||
pub use config::{DevpodCommandConfig, DevpodCommandError}; | ||
|
||
pub mod list_providers; | ||
pub mod use_provider; | ||
pub mod list_workspaces; |
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,31 +1,39 @@ | ||
use crate::providers::ProvidersState; | ||
|
||
use super::{ | ||
config::{CommandConfig, DevpodCommandConfig, DevpodCommandError}, | ||
constants::{ | ||
DEVPOD_BINARY_NAME, DEVPOD_COMMAND_LIST, DEVPOD_COMMAND_PROVIDERS, OUTPUT_JSON_ARG, | ||
DEVPOD_BINARY_NAME, DEVPOD_COMMAND_LIST, DEVPOD_COMMAND_PROVIDER, OUTPUT_JSON_ARG, | ||
}, | ||
}; | ||
use crate::providers::ProvidersState; | ||
|
||
pub struct ListProvidersCommand {} | ||
impl ListProvidersCommand { | ||
pub fn new() -> Self { | ||
ListProvidersCommand {} | ||
} | ||
|
||
fn deserialize(&self, str: &str) -> Result<ProvidersState, DevpodCommandError> { | ||
serde_json::from_str(str).map_err(|err| DevpodCommandError::Parse(err)) | ||
} | ||
} | ||
impl DevpodCommandConfig<ProvidersState> for ListProvidersCommand { | ||
fn config(&self) -> CommandConfig { | ||
fn config(&self) -> CommandConfig { | ||
CommandConfig { | ||
binary_name: DEVPOD_BINARY_NAME, | ||
args: vec![ | ||
DEVPOD_COMMAND_PROVIDERS, | ||
DEVPOD_COMMAND_PROVIDER, | ||
DEVPOD_COMMAND_LIST, | ||
OUTPUT_JSON_ARG, | ||
], | ||
} | ||
} | ||
|
||
fn deserialize(&self, str: &str) -> Result<ProvidersState, DevpodCommandError> { | ||
serde_json::from_str(str).map_err(|err| DevpodCommandError::Parse(err)) | ||
fn exec(self) -> Result<ProvidersState, DevpodCommandError> { | ||
let output = self | ||
.new_command()? | ||
.output() | ||
.map_err(|_| DevpodCommandError::Output)?; | ||
|
||
self.deserialize(&output.stdout) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::{ | ||
config::{CommandConfig, DevpodCommandConfig, DevpodCommandError}, | ||
constants::{DEVPOD_BINARY_NAME, DEVPOD_COMMAND_PROVIDER, DEVPOD_COMMAND_USE}, | ||
}; | ||
|
||
pub struct UseProviderCommand<'a> { | ||
new_provider_id: &'a str, | ||
} | ||
impl<'a> UseProviderCommand<'a> { | ||
pub fn new(new_provider_id: &'a str) -> Self { | ||
UseProviderCommand { new_provider_id } | ||
} | ||
} | ||
impl DevpodCommandConfig<()> for UseProviderCommand<'_> { | ||
fn config(&self) -> CommandConfig { | ||
CommandConfig { | ||
binary_name: DEVPOD_BINARY_NAME, | ||
args: vec![ | ||
DEVPOD_COMMAND_PROVIDER, | ||
DEVPOD_COMMAND_USE, | ||
self.new_provider_id, | ||
], | ||
} | ||
} | ||
|
||
fn exec(self) -> Result<(), DevpodCommandError> { | ||
let cmd = self.new_command()?; | ||
|
||
cmd.status() | ||
.map_err(|err| DevpodCommandError::Failed(err))? | ||
.success() | ||
.then(|| ()) | ||
.ok_or_else(|| DevpodCommandError::Exit) | ||
} | ||
} |
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
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
Oops, something went wrong.