Skip to content

Commit e068fe1

Browse files
committed
Remove non-storage functionality from satorictl
1 parent 37445f7 commit e068fe1

24 files changed

+62
-292
lines changed

Cargo.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ctl/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ satori-storage.workspace = true
1616
tokio.workspace = true
1717
tracing.workspace = true
1818
tracing-subscriber.workspace = true
19-
url.workspace = true

ctl/src/cli/archive/mod.rs

-65
This file was deleted.

ctl/src/cli/debug.rs

-122
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

ctl/src/cli/archive/explore/app/panels/camera_list.rs ctl/src/cli/explore/app/panels/camera_list.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use super::{
22
super::{border_style, highlight_style, App, KeyEventResult, SharedEvent},
33
PanelOperations,
44
};
5-
use crate::cli::archive::explore::{
6-
reset_terminal, setup_terminal, table_scroll::TableScrollState,
7-
};
5+
use crate::cli::explore::{reset_terminal, setup_terminal, table_scroll::TableScrollState};
86
use async_trait::async_trait;
97
use crossterm::event::{KeyCode, KeyEvent};
108
use ratatui::{

ctl/src/cli/archive/explore/app/panels/event_list.rs ctl/src/cli/explore/app/panels/event_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{
22
super::{border_style, highlight_style, App, KeyEventResult, SharedEvent},
33
PanelOperations,
44
};
5-
use crate::cli::archive::explore::table_scroll::TableScrollState;
5+
use crate::cli::explore::table_scroll::TableScrollState;
66
use async_trait::async_trait;
77
use crossterm::event::{KeyCode, KeyEvent};
88
use ratatui::{

ctl/src/cli/archive/explore/app/panels/trigger_list.rs ctl/src/cli/explore/app/panels/trigger_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{
22
super::{border_style, highlight_style, App, KeyEventResult, SharedEvent},
33
PanelOperations,
44
};
5-
use crate::cli::archive::explore::table_scroll::TableScrollState;
5+
use crate::cli::explore::table_scroll::TableScrollState;
66
use async_trait::async_trait;
77
use crossterm::event::{KeyCode, KeyEvent};
88
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.

ctl/src/cli/mod.rs

+48-29
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,66 @@
1-
mod archive;
2-
mod debug;
3-
mod trigger;
1+
mod delete_event;
2+
mod delete_segment;
3+
mod explore;
4+
mod export_video;
5+
mod get_event;
6+
mod get_segment;
7+
mod list_cameras;
8+
mod list_events;
9+
mod list_segments;
10+
mod prune_events;
11+
mod prune_segments;
412

13+
use super::{CliExecute, CliResult, CliResultWithValue};
514
use async_trait::async_trait;
615
use clap::{Parser, Subcommand};
16+
use satori_storage::StorageConfig;
17+
use std::path::PathBuf;
718

8-
pub(crate) type CliResultWithValue<T> = Result<T, ()>;
9-
pub(crate) type CliResult = CliResultWithValue<()>;
10-
11-
#[async_trait]
12-
pub(crate) trait CliExecute {
13-
async fn execute(&self) -> CliResult;
14-
}
15-
16-
/// Control Satori NVR.
19+
/// Interact with a Satori NVR archive target.
1720
#[derive(Debug, Clone, Parser)]
1821
#[command(author, version = satori_common::version!(), about, long_about = None)]
1922
pub(crate) struct Cli {
23+
/// Path to storage configuration.
24+
#[arg(long)]
25+
storage: PathBuf,
26+
2027
#[command(subcommand)]
21-
command: Command,
28+
command: ArchiveSubcommand,
2229
}
2330

2431
#[async_trait]
2532
impl CliExecute for Cli {
2633
async fn execute(&self) -> CliResult {
27-
self.command.execute().await
34+
let storage_config: StorageConfig = satori_common::load_config_file(&self.storage);
35+
let storage = storage_config.create_provider();
36+
37+
match &self.command {
38+
ArchiveSubcommand::ListEvents(cmd) => cmd.execute(storage).await,
39+
ArchiveSubcommand::ListCameras(cmd) => cmd.execute(storage).await,
40+
ArchiveSubcommand::ListSegments(cmd) => cmd.execute(storage).await,
41+
ArchiveSubcommand::GetEvent(cmd) => cmd.execute(storage).await,
42+
ArchiveSubcommand::GetSegment(cmd) => cmd.execute(storage).await,
43+
ArchiveSubcommand::DeleteEvent(cmd) => cmd.execute(storage).await,
44+
ArchiveSubcommand::DeleteSegment(cmd) => cmd.execute(storage).await,
45+
ArchiveSubcommand::PruneEvents(cmd) => cmd.execute(storage).await,
46+
ArchiveSubcommand::PruneSegments(cmd) => cmd.execute(storage).await,
47+
ArchiveSubcommand::ExportVideo(cmd) => cmd.execute(storage).await,
48+
ArchiveSubcommand::Explore(cmd) => cmd.execute(storage).await,
49+
}
2850
}
2951
}
3052

3153
#[derive(Debug, Clone, Subcommand)]
32-
pub(crate) enum Command {
33-
Trigger(trigger::TriggerCommand),
34-
Archive(archive::ArchiveCommand),
35-
Debug(debug::DebugCommand),
36-
}
37-
38-
#[async_trait]
39-
impl CliExecute for Command {
40-
async fn execute(&self) -> CliResult {
41-
match self {
42-
Command::Trigger(cmd) => cmd.execute().await,
43-
Command::Archive(cmd) => cmd.execute().await,
44-
Command::Debug(cmd) => cmd.execute().await,
45-
}
46-
}
54+
pub(crate) enum ArchiveSubcommand {
55+
ListEvents(list_events::ListEventsCommand),
56+
ListCameras(list_cameras::ListCamerasCommand),
57+
ListSegments(list_segments::ListSegmentsCommand),
58+
GetEvent(get_event::GetEventCommand),
59+
GetSegment(get_segment::GetSegmentCommand),
60+
DeleteEvent(delete_event::DeleteEventCommand),
61+
DeleteSegment(delete_segment::DeleteSegmentCommand),
62+
PruneEvents(prune_events::PruneEventsCommand),
63+
PruneSegments(prune_segments::PruneSegmentsCommand),
64+
ExportVideo(export_video::ExportVideoSubcommand),
65+
Explore(explore::ExploreCommand),
4766
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)