Skip to content

Commit

Permalink
Remove non-storage functionality from satorictl
Browse files Browse the repository at this point in the history
DanNixon committed Jan 29, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 37445f7 commit e068fe1
Showing 24 changed files with 62 additions and 292 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ctl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,4 +16,3 @@ satori-storage.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
url.workspace = true
65 changes: 0 additions & 65 deletions ctl/src/cli/archive/mod.rs

This file was deleted.

122 changes: 0 additions & 122 deletions ctl/src/cli/debug.rs

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -2,9 +2,7 @@ use super::{
super::{border_style, highlight_style, App, KeyEventResult, SharedEvent},
PanelOperations,
};
use crate::cli::archive::explore::{
reset_terminal, setup_terminal, table_scroll::TableScrollState,
};
use crate::cli::explore::{reset_terminal, setup_terminal, table_scroll::TableScrollState};
use async_trait::async_trait;
use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use super::{
super::{border_style, highlight_style, App, KeyEventResult, SharedEvent},
PanelOperations,
};
use crate::cli::archive::explore::table_scroll::TableScrollState;
use crate::cli::explore::table_scroll::TableScrollState;
use async_trait::async_trait;
use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use super::{
super::{border_style, highlight_style, App, KeyEventResult, SharedEvent},
PanelOperations,
};
use crate::cli::archive::explore::table_scroll::TableScrollState;
use crate::cli::explore::table_scroll::TableScrollState;
use async_trait::async_trait;
use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{
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.
77 changes: 48 additions & 29 deletions ctl/src/cli/mod.rs
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.
Loading

0 comments on commit e068fe1

Please sign in to comment.