-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: start of main subcommand to handle requests from git
- Loading branch information
Showing
9 changed files
with
99 additions
and
10 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,5 @@ | ||
use anyhow::Result; | ||
|
||
pub trait CustomTransferAgent { | ||
async fn init(&mut self) -> 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use anyhow::Result; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::CustomTransferAgent; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
#[serde[rename_all = "snake_case"]] | ||
struct Event { | ||
event: String, | ||
operation: String, | ||
remote: String, | ||
concurrent: bool | ||
} | ||
|
||
pub struct GitLfsParser<'custom_transfer_agent, T: CustomTransferAgent> { | ||
custom_transfer_agent: &'custom_transfer_agent mut T | ||
} | ||
|
||
impl<'custom_transfer_agent, T: CustomTransferAgent> GitLfsParser<'custom_transfer_agent, T> { | ||
pub fn new(custom_transfer_agent: &mut T) -> GitLfsParser::<T> { | ||
GitLfsParser::<T> { | ||
custom_transfer_agent | ||
} | ||
} | ||
|
||
pub async fn listen(&mut self) -> Result<()> { | ||
self.custom_transfer_agent.init().await?; | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod custom_transfer_agent; | ||
mod git_lfs_parser; | ||
|
||
pub use custom_transfer_agent::CustomTransferAgent; | ||
pub use git_lfs_parser::GitLfsParser; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use anyhow::Result; | ||
use clap::ArgMatches; | ||
|
||
use crate::{credential_manager::CredentialManager, git_lfs::{CustomTransferAgent, GitLfsParser}}; | ||
|
||
use super::Subcommand; | ||
|
||
#[derive(Debug)] | ||
pub struct MainSubcommand { | ||
credential_manager: Option<CredentialManager> | ||
} | ||
|
||
impl CustomTransferAgent for MainSubcommand { | ||
async fn init(&mut self) -> Result<()> { | ||
// Init credential manager | ||
// Init synology api | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl Subcommand for MainSubcommand { | ||
#[tracing::instrument] | ||
async fn execute(&mut self, arg_matches: &ArgMatches) -> Result<()> { | ||
let mut parser = GitLfsParser::<MainSubcommand>::new(self); | ||
parser.listen().await?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl MainSubcommand { | ||
pub fn new() -> MainSubcommand { | ||
MainSubcommand { | ||
credential_manager: None | ||
} | ||
} | ||
} |
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,7 +1,9 @@ | ||
mod subcommand; | ||
mod login_subcommand; | ||
mod logout_subcommand; | ||
mod main_subcommand; | ||
mod subcommand; | ||
|
||
pub use login_subcommand::LoginSubcommand; | ||
pub use logout_subcommand::LogoutSubcommand; | ||
pub use main_subcommand::MainSubcommand; | ||
pub use subcommand::Subcommand; |
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