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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
use crate::completion;
use crate::version;
use clap::{Args, Parser, Subcommand, ValueEnum};
use super::{
AppCommands, EnvCommands, LocalCommands, PresetCommands, SelfCommands, ServeCommands,
ShellCommands, StateCommands, SysCommands, TaskCommands, TaskRunCommand, ThemeCommands,
};
/// Manage shell presets, app configs, system setup, and personal tools
#[derive(Parser, Debug)]
#[command(name = "shine")]
#[command(version = version::display(), about, long_about = None)]
#[command(
after_help = "QUICK START:\n shine list --available\n shine info app/starship\n shine install app/starship\n shine update && shine upgrade\n\nTARGETS:\n Use app/<category>, shell/<category>, or sys/<item>. A bare app/shell category is accepted when unique.\n\nNAMESPACES:\n app, shell, and sys expose resource-specific operations; preset, state, self, serve, completions, theme, and local are advanced tools."
)]
pub struct Cli {
#[arg(long, global = true)]
pub config_dir: Option<String>,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
#[command(name = "__shell-render", hide = true)]
ShellRender {
#[arg(value_name = "TARGET")]
target: String,
},
/// Initialize the current directory as a shine presets directory
Init(InitCommand),
/// Manage shell command presets
Shell {
#[command(subcommand)]
command: ShellCommands,
},
/// Manage application configuration presets
App {
#[command(subcommand)]
command: AppCommands,
},
/// Install or repair one shell or app preset
Install {
/// Preset target: app/<category>, shell/<category>, or a unique category name
#[arg(value_name = "TARGET")]
target: String,
/// Replace user-modified files that are already managed by shine
#[arg(long)]
replace_managed: bool,
},
/// Uninstall one shell or app preset
Uninstall {
/// Preset target: app/<category>, shell/<category>, or a unique category name
#[arg(value_name = "TARGET")]
target: String,
/// Remove managed files even when they were modified after installation (app only)
#[arg(long)]
force: bool,
/// Also remove empty managed preset directories
#[arg(long)]
purge: bool,
/// Print what would be removed without changing anything
#[arg(long)]
dry_run: bool,
},
/// Generate or install shell completion scripts
Completions {
#[command(subcommand)]
command: CompletionCommands,
},
/// List installed resources, or browse available resources with --available
List {
/// List available resources instead of installed resources
#[arg(long)]
available: bool,
/// Limit --available output to app, shell, or sys resources
#[arg(value_enum, requires = "available", value_name = "KIND")]
kind: Option<ResourceKind>,
},
/// Show details for an available or installed app/shell target, or `sys/<ITEM>`
Info {
/// Installed item to inspect (e.g. git, starship, proxy, setproxy)
#[arg(value_name = "TARGET")]
target: String,
/// Also print a unified diff against the expected content
#[arg(long)]
diff: bool,
/// Also print the installed or rendered file content
#[arg(long)]
verbose: bool,
},
/// Manage preset sources, overlays, exports, and Git synchronization
Preset {
#[command(subcommand)]
command: PresetCommands,
},
/// Check managed configuration and shine release updates
Update(UpdateCommand),
/// Apply available managed configuration updates
Upgrade(UpgradeCommand),
/// Manage shine-owned runtime state
State {
#[command(subcommand)]
command: StateCommands,
},
/// Manage the shine binary itself
#[command(name = "self")]
Self_ {
#[command(subcommand)]
command: SelfCommands,
},
/// Serve shine-managed HTTP resources from ~/.shine/http
Serve {
#[command(subcommand)]
command: ServeCommands,
},
/// Manage preset variables and workspace command environments
Env {
#[command(subcommand)]
command: EnvCommands,
},
/// Manage system bootstrap and configuration for the current OS
Sys {
#[command(subcommand)]
command: SysCommands,
},
/// Resolve and sync the terminal's light/dark theme (see `shine theme sync`)
Theme {
#[command(subcommand)]
command: ThemeCommands,
},
/// Open an interactive SSH session with a session-scoped file transfer channel
Ssh {
/// Remote command shell (must appear before the SSH destination).
/// Windows mode injects environment variables only; `shine local` is unavailable.
#[arg(long, value_enum, default_value_t = RemoteShell::Posix)]
remote_shell: RemoteShell,
/// Inject a plaintext config [env] value as KEY or KEY=ALIAS (repeatable;
/// must appear before the SSH destination)
#[arg(long = "with", value_name = "KEY[=ALIAS]")]
with: Vec<String>,
/// Decrypt KEY_SECRET and inject it as KEY or ALIAS (repeatable; must
/// appear before the SSH destination)
#[arg(long = "with-secret", value_name = "KEY[=ALIAS]")]
with_secret: Vec<String>,
/// ssh options, the destination, and an optional remote command
/// (passed through to the system `ssh` binary; see `ssh(1)`)
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<String>,
},
/// Transfer files between this machine and the other end of a `shine ssh` session
Local {
#[command(subcommand)]
command: LocalCommands,
},
/// Save, run, and manage personal shortcut commands
Task {
#[command(subcommand)]
command: TaskCommands,
},
/// Run a saved task (alias for `shine task run`)
Run(TaskRunCommand),
}
/// Shell used by the remote SSH server to interpret Shine's command wrapper.
#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
pub enum RemoteShell {
/// POSIX shell with session-scoped `shine local` file transfer support.
Posix,
/// Windows PowerShell environment injection only; `shine local` is unavailable.
Windows,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
pub enum ResourceKind {
App,
Shell,
Sys,
}
#[derive(Args, Debug)]
pub struct InitCommand {
/// Skip the confirmation prompt
#[arg(long)]
pub yes: bool,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
pub enum CompletionShell {
#[value(name = "bash")]
Bash,
#[value(name = "powershell")]
PowerShell,
#[value(name = "zsh")]
Zsh,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Subcommand)]
pub enum CompletionCommands {
/// Install completions into the managed shell profile without installing presets
Install,
/// Generate bash completion registration script
Bash,
/// Generate PowerShell completion registration script
#[command(name = "powershell")]
PowerShell,
/// Generate zsh completion registration script
Zsh,
}
impl CompletionCommands {
pub fn generate(self) {
match self {
CompletionCommands::Bash => completion::generate_registration(CompletionShell::Bash),
CompletionCommands::PowerShell => {
completion::generate_registration(CompletionShell::PowerShell)
}
CompletionCommands::Zsh => completion::generate_registration(CompletionShell::Zsh),
CompletionCommands::Install => unreachable!("install is handled by the async runtime"),
}
}
}
impl CompletionShell {
pub fn from_command(command: &CompletionCommands) -> Option<Self> {
match command {
CompletionCommands::Bash => Some(CompletionShell::Bash),
CompletionCommands::PowerShell => Some(CompletionShell::PowerShell),
CompletionCommands::Zsh => Some(CompletionShell::Zsh),
CompletionCommands::Install => None,
}
}
pub fn as_str(self) -> &'static str {
match self {
CompletionShell::Bash => "bash",
CompletionShell::PowerShell => "powershell",
CompletionShell::Zsh => "zsh",
}
}
}
#[derive(Parser, Debug)]
pub struct UpdateCommand {
/// Installed shell or app target to inspect (shows pending content differences)
#[arg(value_name = "TARGET")]
pub target: Option<String>,
/// Pull Git-managed preset sources before checking status
#[arg(long)]
pub pull: bool,
/// Show content differences for available shell and app updates
#[arg(long)]
pub diff: bool,
/// Show installed entries that are already current or need attention
#[arg(long, conflicts_with = "target")]
pub verbose: bool,
/// Bypass the 24-hour version cache and check GitHub now
#[arg(long, conflicts_with = "target")]
pub refresh_release: bool,
}
#[derive(Parser, Debug)]
pub struct UpgradeCommand {
/// Installed app, shell, or managed sys target to upgrade
#[arg(value_name = "TARGET")]
pub target: Option<String>,
/// Pull Git-managed preset sources before upgrading installed configs
#[arg(long)]
pub pull: bool,
/// Show detailed env-template checks and skipped rows
#[arg(long)]
pub verbose: bool,
/// Remove stale managed app files whose preset source no longer exists
#[arg(long)]
pub prune_stale: bool,
}