Skip to main content

telarex_core/command/
mod.rs

1//! Command enumeration — a typed set of every action the editor can perform.
2//!
3//! [`Command`] covers file operations, git integration, workspace sharing,
4//! and application lifecycle. It provides human-readable names and descriptions
5//! for use in command palettes and keybinding displays.
6
7/// A typed action the editor can perform — file ops, git, network, and lifecycle.
8///
9/// Each variant has a human-readable [`name`](Command::name) and
10/// [`description`](Command::description) for UI display.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
12pub enum Command {
13    OpenFile,
14    Save,
15    SaveAs,
16    Quit,
17    ToggleExplorer,
18    OpenConfig,
19    ShareWorkspace,
20    LeaveWorkspace,
21    DisconnectNetwork,
22    ResetData,
23    GitStatus,
24    GitStageAll,
25    GitCommit,
26    GitPush,
27    GitPull,
28    GitLog,
29}
30
31impl Command {
32    /// Return every available command variant.
33    pub fn all() -> Vec<Command> {
34        vec![
35            Command::OpenFile,
36            Command::Save,
37            Command::ToggleExplorer,
38            Command::OpenConfig,
39            Command::ShareWorkspace,
40            Command::LeaveWorkspace,
41            Command::DisconnectNetwork,
42            Command::ResetData,
43            Command::GitStatus,
44            Command::GitStageAll,
45            Command::GitCommit,
46            Command::GitPush,
47            Command::GitPull,
48            Command::GitLog,
49            Command::Quit,
50        ]
51    }
52
53    /// Return a short, human-readable name for this command.
54    pub fn name(&self) -> &'static str {
55        match self {
56            Command::OpenFile => "Open File",
57            Command::Save => "Save",
58            Command::SaveAs => "Save As",
59            Command::Quit => "Quit",
60            Command::ToggleExplorer => "Toggle File Explorer",
61            Command::OpenConfig => "Open Configuration",
62            Command::ShareWorkspace => "Share Workspace (Lodge)",
63            Command::LeaveWorkspace => "Leave Lodge",
64            Command::DisconnectNetwork => "Disconnect from Network",
65            Command::ResetData => "Reset Application Data",
66            Command::GitStatus => "Git Status",
67            Command::GitStageAll => "Git Stage All",
68            Command::GitCommit => "Git Commit",
69            Command::GitPush => "Git Push",
70            Command::GitPull => "Git Pull",
71            Command::GitLog => "Git Log",
72        }
73    }
74
75    /// Return a longer description explaining what this command does.
76    pub fn description(&self) -> &'static str {
77        match self {
78            Command::OpenFile => "Open a file from the filesystem",
79            Command::Save => "Save the current file",
80            Command::SaveAs => "Save the current file with a new name",
81            Command::Quit => "Exit TelaRex",
82            Command::ToggleExplorer => "Show or hide the file explorer panel",
83            Command::OpenConfig => "Open TelaRex settings",
84            Command::ShareWorkspace => "Broadcast this workspace to the network as a Lodge",
85            Command::LeaveWorkspace => "Stop sharing or exit current lodge",
86            Command::DisconnectNetwork => "Shutdown all peer-to-peer connectivity",
87            Command::ResetData => "Wipe all local configuration and database records",
88            Command::GitStatus => "Show working tree status in the log",
89            Command::GitStageAll => "Stage all changes for commit",
90            Command::GitCommit => "Commit staged changes with a message",
91            Command::GitPush => "Push commits to remote origin",
92            Command::GitPull => "Fetch and merge from remote origin",
93            Command::GitLog => "Show recent commit history",
94        }
95    }
96}