-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove non-storage functionality from satorictl
Showing
24 changed files
with
62 additions
and
292 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,47 +1,66 @@ | ||
mod archive; | ||
mod debug; | ||
mod trigger; | ||
mod delete_event; | ||
mod delete_segment; | ||
mod explore; | ||
mod export_video; | ||
mod get_event; | ||
mod get_segment; | ||
mod list_cameras; | ||
mod list_events; | ||
mod list_segments; | ||
mod prune_events; | ||
mod prune_segments; | ||
|
||
use super::{CliExecute, CliResult, CliResultWithValue}; | ||
use async_trait::async_trait; | ||
use clap::{Parser, Subcommand}; | ||
use satori_storage::StorageConfig; | ||
use std::path::PathBuf; | ||
|
||
pub(crate) type CliResultWithValue<T> = Result<T, ()>; | ||
pub(crate) type CliResult = CliResultWithValue<()>; | ||
|
||
#[async_trait] | ||
pub(crate) trait CliExecute { | ||
async fn execute(&self) -> CliResult; | ||
} | ||
|
||
/// Control Satori NVR. | ||
/// Interact with a Satori NVR archive target. | ||
#[derive(Debug, Clone, Parser)] | ||
#[command(author, version = satori_common::version!(), about, long_about = None)] | ||
pub(crate) struct Cli { | ||
/// Path to storage configuration. | ||
#[arg(long)] | ||
storage: PathBuf, | ||
|
||
#[command(subcommand)] | ||
command: Command, | ||
command: ArchiveSubcommand, | ||
} | ||
|
||
#[async_trait] | ||
impl CliExecute for Cli { | ||
async fn execute(&self) -> CliResult { | ||
self.command.execute().await | ||
let storage_config: StorageConfig = satori_common::load_config_file(&self.storage); | ||
let storage = storage_config.create_provider(); | ||
|
||
match &self.command { | ||
ArchiveSubcommand::ListEvents(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::ListCameras(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::ListSegments(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::GetEvent(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::GetSegment(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::DeleteEvent(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::DeleteSegment(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::PruneEvents(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::PruneSegments(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::ExportVideo(cmd) => cmd.execute(storage).await, | ||
ArchiveSubcommand::Explore(cmd) => cmd.execute(storage).await, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Subcommand)] | ||
pub(crate) enum Command { | ||
Trigger(trigger::TriggerCommand), | ||
Archive(archive::ArchiveCommand), | ||
Debug(debug::DebugCommand), | ||
} | ||
|
||
#[async_trait] | ||
impl CliExecute for Command { | ||
async fn execute(&self) -> CliResult { | ||
match self { | ||
Command::Trigger(cmd) => cmd.execute().await, | ||
Command::Archive(cmd) => cmd.execute().await, | ||
Command::Debug(cmd) => cmd.execute().await, | ||
} | ||
} | ||
pub(crate) enum ArchiveSubcommand { | ||
ListEvents(list_events::ListEventsCommand), | ||
ListCameras(list_cameras::ListCamerasCommand), | ||
ListSegments(list_segments::ListSegmentsCommand), | ||
GetEvent(get_event::GetEventCommand), | ||
GetSegment(get_segment::GetSegmentCommand), | ||
DeleteEvent(delete_event::DeleteEventCommand), | ||
DeleteSegment(delete_segment::DeleteSegmentCommand), | ||
PruneEvents(prune_events::PruneEventsCommand), | ||
PruneSegments(prune_segments::PruneSegmentsCommand), | ||
ExportVideo(export_video::ExportVideoSubcommand), | ||
Explore(explore::ExploreCommand), | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.