Bundle CLI launchers with desktop app
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
mod action;
|
||||
mod editor;
|
||||
mod folder_picker;
|
||||
mod launcher;
|
||||
#[cfg(target_os = "macos")]
|
||||
mod native_menu;
|
||||
mod navigation;
|
||||
@@ -107,6 +108,7 @@ enum Message {
|
||||
SettingsTimeoutChanged(String),
|
||||
PickSettingsVault,
|
||||
SettingsVaultPicked(Result<Option<PathBuf>, String>),
|
||||
InstallCommandLinks,
|
||||
SaveSettings,
|
||||
SettingsFinished {
|
||||
generation: u64,
|
||||
@@ -780,6 +782,7 @@ struct SettingsForm {
|
||||
authentication_timeout: String,
|
||||
saving: bool,
|
||||
error: Option<String>,
|
||||
command_links_status: Option<String>,
|
||||
}
|
||||
|
||||
impl SettingsForm {
|
||||
@@ -794,6 +797,7 @@ impl SettingsForm {
|
||||
.to_string(),
|
||||
saving: false,
|
||||
error: None,
|
||||
command_links_status: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1054,6 +1058,22 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::InstallCommandLinks => {
|
||||
if let Some(UtilityView::Settings(form)) = &mut self.utility
|
||||
&& !form.saving
|
||||
{
|
||||
form.command_links_status =
|
||||
Some(match launcher::install_packaged_launchers() {
|
||||
Ok(targets) => format!(
|
||||
"Installed {} and {}.",
|
||||
targets[0].display(),
|
||||
targets[1].display()
|
||||
),
|
||||
Err(error) => format!("Command links were not installed: {error}"),
|
||||
});
|
||||
self.status = form.command_links_status.clone().unwrap_or_default();
|
||||
}
|
||||
}
|
||||
Message::SaveSettings => return self.begin_settings_save(),
|
||||
Message::SettingsFinished { generation, result } => {
|
||||
if generation != self.settings_generation {
|
||||
@@ -3918,7 +3938,19 @@ fn utility_view<'a>(app: &'a App, utility: &'a UtilityView) -> Element<'a, Messa
|
||||
text_input("Timeout seconds", &form.authentication_timeout)
|
||||
.on_input(Message::SettingsTimeoutChanged)
|
||||
.on_submit(Message::SaveSettings),
|
||||
);
|
||||
)
|
||||
.push(text("Command-line tools"))
|
||||
.push(text(
|
||||
"Install links to the CLI and TUI embedded in this application bundle in ~/.local/bin. Existing command files or links are replaced.",
|
||||
))
|
||||
.push(if form.saving {
|
||||
button("Install CLI and TUI Links")
|
||||
} else {
|
||||
button("Install CLI and TUI Links").on_press(Message::InstallCommandLinks)
|
||||
});
|
||||
if let Some(status) = &form.command_links_status {
|
||||
content = content.push(text(status));
|
||||
}
|
||||
if let Some(storage) = &app.storage {
|
||||
content = content
|
||||
.push(text(format!(
|
||||
|
||||
Reference in New Issue
Block a user