Add command for Chromium manifest
This commit is contained in:
parent
1c47fe8c98
commit
a3388efb97
2 changed files with 12 additions and 3 deletions
|
@ -10,6 +10,7 @@ use crate::error::FF2MpvError;
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
ShowHelp,
|
ShowHelp,
|
||||||
ShowManifest,
|
ShowManifest,
|
||||||
|
ShowManifestChromium,
|
||||||
ValidateConfig,
|
ValidateConfig,
|
||||||
FF2Mpv
|
FF2Mpv
|
||||||
}
|
}
|
||||||
|
@ -19,7 +20,8 @@ impl Command {
|
||||||
pub fn execute(&self) -> Result<(), FF2MpvError> {
|
pub fn execute(&self) -> Result<(), FF2MpvError> {
|
||||||
match self {
|
match self {
|
||||||
Command::ShowHelp => Self::show_help(),
|
Command::ShowHelp => Self::show_help(),
|
||||||
Command::ShowManifest => Self::show_manifest(),
|
Command::ShowManifest => Self::show_manifest(false),
|
||||||
|
Command::ShowManifestChromium => Self::show_manifest(true),
|
||||||
Command::ValidateConfig => Self::validate_config(),
|
Command::ValidateConfig => Self::validate_config(),
|
||||||
Command::FF2Mpv => Self::ff2mpv()
|
Command::FF2Mpv => Self::ff2mpv()
|
||||||
}
|
}
|
||||||
|
@ -37,14 +39,20 @@ impl Command {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_manifest() -> Result<(), FF2MpvError>{
|
fn show_manifest(chromium: bool) -> Result<(), FF2MpvError> {
|
||||||
let executable_path = env::current_exe()?;
|
let executable_path = env::current_exe()?;
|
||||||
|
let allowed_keyvalue = if chromium {
|
||||||
|
("allowed_origins", "chrome-extension://ephjcajbkgplkjmelpglennepbpmdpjg")
|
||||||
|
} else {
|
||||||
|
("allowed_extensions", "ff2mpv@yossarian.net")
|
||||||
|
};
|
||||||
|
|
||||||
let manifest = json!({
|
let manifest = json!({
|
||||||
"name": "ff2mpv",
|
"name": "ff2mpv",
|
||||||
"description": "ff2mpv's external manifest",
|
"description": "ff2mpv's external manifest",
|
||||||
"path": executable_path,
|
"path": executable_path,
|
||||||
"type": "stdio",
|
"type": "stdio",
|
||||||
"allowed_extensions": ["ff2mpv@yossarian.net"]
|
allowed_keyvalue.0: [allowed_keyvalue.1]
|
||||||
});
|
});
|
||||||
|
|
||||||
let manifest = serde_json::to_string_pretty(&manifest)?;
|
let manifest = serde_json::to_string_pretty(&manifest)?;
|
||||||
|
|
|
@ -19,6 +19,7 @@ fn get_command(name: &str) -> Command {
|
||||||
match name {
|
match name {
|
||||||
"help" => Command::ShowHelp,
|
"help" => Command::ShowHelp,
|
||||||
"manifest" => Command::ShowManifest,
|
"manifest" => Command::ShowManifest,
|
||||||
|
"manifest_chromium" => Command::ShowManifestChromium,
|
||||||
"validate" => Command::ValidateConfig,
|
"validate" => Command::ValidateConfig,
|
||||||
_ => Command::FF2Mpv,
|
_ => Command::FF2Mpv,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue