-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_surface.rs
More file actions
114 lines (106 loc) · 3.69 KB
/
command_surface.rs
File metadata and controls
114 lines (106 loc) · 3.69 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use std::fmt::Write;
use crate::services;
use services::style::{command_name, heading};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ImplementationStatus {
Implemented,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CommandContract {
pub name: &'static str,
pub status: ImplementationStatus,
pub purpose: &'static str,
pub show_in_top_level_help: bool,
}
pub const COMMANDS: &[CommandContract] = &[
CommandContract {
name: "help",
status: ImplementationStatus::Implemented,
purpose: "Show help for the current CLI surface",
show_in_top_level_help: true,
},
CommandContract {
name: services::config::NAME,
status: ImplementationStatus::Implemented,
purpose: "Inspect and validate resolved CLI configuration",
show_in_top_level_help: true,
},
CommandContract {
name: services::setup::NAME,
status: ImplementationStatus::Implemented,
purpose: "Prepare local repository/workspace prerequisites",
show_in_top_level_help: true,
},
CommandContract {
name: services::doctor::NAME,
status: ImplementationStatus::Implemented,
purpose: "Inspect SCE operator health and explicit repair readiness",
show_in_top_level_help: true,
},
CommandContract {
name: services::auth_command::NAME,
status: ImplementationStatus::Implemented,
purpose: "Authenticate with WorkOS and inspect local auth state",
show_in_top_level_help: false,
},
CommandContract {
name: services::hooks::NAME,
status: ImplementationStatus::Implemented,
purpose: "Run attribution-only git hooks (disabled by default)",
show_in_top_level_help: false,
},
CommandContract {
name: services::version::NAME,
status: ImplementationStatus::Implemented,
purpose: "Print deterministic runtime version metadata",
show_in_top_level_help: true,
},
CommandContract {
name: services::completion::NAME,
status: ImplementationStatus::Implemented,
purpose: "Generate deterministic shell completion scripts",
show_in_top_level_help: true,
},
];
pub fn is_known_command(name: &str) -> bool {
COMMANDS.iter().any(|command| command.name == name)
}
pub fn help_text() -> String {
let mut command_rows = String::new();
for command in COMMANDS {
if !command.show_in_top_level_help {
continue;
}
writeln!(
command_rows,
" {:<10} {}",
command_name(command.name),
command.purpose
)
.expect("writing to String should never fail");
}
format!(
"{}\n\n\
{}:\n sce [command]\n\n\
{}:\n {} <show|validate> [--format <text|json>] [options]\n\n\
{}:\n {} [--opencode|--claude|--both] [--non-interactive] [--hooks] [--repo <path>]\n\n\
{}:\n {} [--fix] [--format <text|json>]\n\n\
{}:\n {} --shell <bash|zsh|fish>\n\n\
{}:\n Supported commands accept --format <text|json>\n\n\
{}:\n sce setup\n sce setup --opencode --non-interactive --hooks\n sce setup --hooks --repo ../demo-repo\n sce doctor --format json\n sce doctor --fix\n sce version --format json\n\n\
{}:\n{command_rows}",
heading("sce - Shared Context Engineering CLI"),
heading("Usage"),
heading("Config usage"),
command_name("sce config"),
heading("Setup usage"),
command_name("sce setup"),
heading("Doctor usage"),
command_name("sce doctor"),
heading("Completion usage"),
command_name("sce completion"),
heading("Output format contract"),
heading("Examples"),
heading("Commands"),
)
}