1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use crate::cli::command::fsutil::FsutilArgs;
use crate::cli::command::install::InstallArgs;
use crate::cli::command::list_paths::ListPathsArgs;
use crate::cli::command::r#move::MoveArgs;
use crate::cli::command::profile::ProfileArgs;
use crate::cli::command::protection::ProtectionArgs;
use crate::cli::command::query::QueryArgs;
use crate::cli::command::rules::RuleArgs;
use crate::cli::command::service::ServiceArgs;
use crate::cli::command::status::StatusArgs;
use crate::cli::command::sync::SyncArgs;
use crate::cli::command::tray::TrayArgs;
use crate::cli::command::uninstall::UninstallArgs;
use arbitrary::Arbitrary;
use facet::Facet;
use figue::{self as args};
/// Teamy MFT commands
// cli[impl command.surface.core]
// tool[impl cli.help.describes-behavior]
#[derive(Facet, Arbitrary, PartialEq, Debug)]
#[repr(u8)]
pub enum Command {
/// Compatibility alias for `service`
Daemon(ServiceArgs),
/// Manage the machine-wide Windows service that hosts the daemon
Service(ServiceArgs),
/// Write `.mft` and `.mft_search_index` files (will auto-elevate via UAC if not already running as administrator)
Sync(SyncArgs),
/// Configure the machine-wide cache and optionally install the daemon service
Install(InstallArgs),
/// Helper for `service uninstall`
Uninstall(UninstallArgs),
/// Produce newline-delimited list of file paths for matching drives from cached `.mft` files
ListPaths(ListPathsArgs),
/// Move one file and automatically refresh the published overlay for the old and new paths
#[facet(args::alias = "mv")]
Move(MoveArgs),
/// Manage discovered `.teamy_mft_rules` profile rules used to filter query results
#[facet(args::alias = "rules")]
Rule(RuleArgs),
/// Manage query rule profiles discovered from `.teamy_mft_rules` files
#[facet(args::alias = "profiles")]
Profile(ProfileArgs),
/// Toggle machine cache ACL protection for development workflows
Protection(ProtectionArgs),
/// Native Windows filesystem utilities used by teamy-mft
Fsutil(FsutilArgs),
/// Show per-drive cache freshness for `.mft` and `.mft_search_index` files
Status(StatusArgs),
/// Query indexed file paths (substring match) across cached `.mft_search_index` files
Query(QueryArgs),
/// Launch the Windows tray icon for daemon log replay and live follow
Tray(TrayArgs),
}
impl Default for Command {
fn default() -> Self {
Command::Status(StatusArgs::default())
}
}
impl Command {
/// Invoke the command with global arguments.
///
/// # Errors
///
/// Returns an error if tracing initialization fails or the command execution fails.
pub fn invoke(self) -> eyre::Result<()> {
match self {
Command::Daemon(args) | Command::Service(args) => args.invoke(),
Command::Sync(args) => args.invoke(),
Command::Install(args) => args.invoke(),
Command::Uninstall(args) => args.invoke(),
Command::ListPaths(args) => args.invoke(),
Command::Move(args) => args.invoke(),
Command::Rule(args) => args.invoke(),
Command::Profile(args) => args.invoke(),
Command::Protection(args) => args.invoke(),
Command::Fsutil(args) => args.invoke(),
Command::Status(args) => args.invoke(),
Command::Query(args) => args.invoke_and_print(),
Command::Tray(args) => args.invoke(),
}
}
}