返回 CodeWhale
mod.rs
根目录 / crates / tui / src / commands / groups / session / mod.rs
1 //! Portable session command group. Host observations, registration and action
2 //! execution live outside this complete source closure.
3
4 use codewhale_command_contract::handler::CommandHandler;
5 use codewhale_command_contract::metadata::{CommandInfo, RegisterCommand};
6 use codewhale_command_contract::outcome::SessionCommandResult as CommandResult;
7
8 pub(in crate::commands) mod branch;
9 pub(in crate::commands) mod compact;
10 pub(in crate::commands) mod export;
11 pub(in crate::commands) mod fork;
12 pub(in crate::commands) mod load;
13 pub(in crate::commands) mod new;
14 pub(in crate::commands) mod purge;
15 pub(in crate::commands) mod relay;
16 pub(in crate::commands) mod remote_control;
17 pub(in crate::commands) mod remote_env;
18 pub(in crate::commands) mod rename;
19 pub(in crate::commands) mod resume;
20 pub(in crate::commands) mod save;
21 pub(in crate::commands) mod sessions;
22 pub(in crate::commands) mod structcopy;
23 pub(in crate::commands) mod title;
24 pub(in crate::commands) mod tree;
25 // Documentation-only child, retained with the established source topology.
26 #[allow(clippy::module_inception)]
27 mod session;
28
29 pub(in crate::commands) const MAX_TITLE_LEN: usize = 100;
30
31 /// Promote the no-action structcopy result to the group's action vocabulary.
32 /// The leaf itself retains its narrower, impossible-action return type.
33 pub(in crate::commands) struct StructcopyRegistration;
34 impl RegisterCommand<CommandResult> for StructcopyRegistration {
35 fn info() -> &'static CommandInfo {
36 structcopy::StructcopyCmd::info()
37 }
38 fn handler() -> CommandHandler<CommandResult> {
39 CommandHandler::Contextual {
40 capabilities: structcopy::CAPABILITIES,
41 handler: |contexts, args| {
42 let result = structcopy::execute_structcopy(contexts, args);
43 CommandResult {
44 message: result.message,
45 action: result.action.map(|impossible| match impossible {}),
46 is_error: result.is_error,
47 }
48 },
49 }
50 }
51 }
52
53 /// Complete group inventory, used by the host and independent compilation proof.
54 pub fn portable_handlers() -> [(&'static CommandInfo, CommandHandler<CommandResult>); 17] {
55 [
56 (rename::RenameCmd::info(), rename::RenameCmd::handler()),
57 (title::TitleCmd::info(), title::TitleCmd::handler()),
58 (save::SaveCmd::info(), save::SaveCmd::handler()),
59 (fork::ForkCmd::info(), fork::ForkCmd::handler()),
60 (new::NewCmd::info(), new::NewCmd::handler()),
61 (
62 sessions::SessionsCmd::info(),
63 sessions::SessionsCmd::handler(),
64 ),
65 (load::LoadCmd::info(), load::LoadCmd::handler()),
66 (resume::ResumeCmd::info(), resume::ResumeCmd::handler()),
67 (tree::TreeCmd::info(), tree::TreeCmd::handler()),
68 (branch::BranchCmd::info(), branch::BranchCmd::handler()),
69 (compact::CompactCmd::info(), compact::CompactCmd::handler()),
70 (purge::PurgeCmd::info(), purge::PurgeCmd::handler()),
71 (relay::RelayCmd::info(), relay::RelayCmd::handler()),
72 (
73 remote_control::RemoteControlCmd::info(),
74 remote_control::RemoteControlCmd::handler(),
75 ),
76 (
77 remote_env::RemoteEnvCmd::info(),
78 remote_env::RemoteEnvCmd::handler(),
79 ),
80 (export::ExportCmd::info(), export::ExportCmd::handler()),
81 (
82 StructcopyRegistration::info(),
83 StructcopyRegistration::handler(),
84 ),
85 ]
86 }
87
88 #[cfg(test)]
89 mod control_test_support;
90 #[cfg(test)]
91 mod lifecycle_portable_tests;
92 #[cfg(test)]
93 mod lifecycle_test_support;
94
94 lines RUST