Implement the shared automation CLI.
This commit is contained in:
@@ -903,10 +903,7 @@ impl BdsApp {
|
||||
let os_locale = detect_os_locale();
|
||||
|
||||
// Open or create the database
|
||||
let db_path = dirs::data_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
.join("bds")
|
||||
.join("bds.db");
|
||||
let db_path = bds_core::util::application_database_path();
|
||||
|
||||
// Ensure parent directory exists
|
||||
if let Some(parent) = db_path.parent() {
|
||||
@@ -946,10 +943,7 @@ impl BdsApp {
|
||||
// If no projects exist, ensure the default project per spec
|
||||
let init_task = if projects.is_empty() {
|
||||
if let Some(ref db) = db {
|
||||
let default_data = dirs::home_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
.join("bds")
|
||||
.join("my-blog");
|
||||
let default_data = bds_core::util::default_project_data_dir();
|
||||
match engine::project::ensure_default_project(db.conn(), Some(&default_data)) {
|
||||
Ok(project) => Task::done(Message::ProjectsLoaded(vec![project])),
|
||||
Err(_) => Task::none(),
|
||||
@@ -5972,6 +5966,22 @@ impl BdsApp {
|
||||
let _ = open::that(dir);
|
||||
}
|
||||
}
|
||||
SettingsMsg::InstallCli => {
|
||||
let home = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
|
||||
match engine::cli_launcher::install_packaged_launcher(&home) {
|
||||
Ok(path) => self.notify(
|
||||
ToastLevel::Success,
|
||||
&tw(
|
||||
self.ui_locale,
|
||||
"settings.cliInstalled",
|
||||
&[("path", &path.to_string_lossy())],
|
||||
),
|
||||
),
|
||||
Err(error) => {
|
||||
self.notify_operation_failed("settings.installCli", error.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
SettingsMsg::FocusSection(section) => {
|
||||
state.focus_section(section);
|
||||
}
|
||||
|
||||
@@ -344,6 +344,7 @@ pub enum SettingsMsg {
|
||||
RebuildSearchIndex,
|
||||
RegenerateThumbnails,
|
||||
OpenDataFolder,
|
||||
InstallCli,
|
||||
/// Navigate to a specific section from sidebar; expand it, collapse all others.
|
||||
FocusSection(SettingsSection),
|
||||
}
|
||||
@@ -996,7 +997,12 @@ fn section_data<'a>(locale: UiLocale) -> Element<'a, Message> {
|
||||
.style(inputs::secondary_button)
|
||||
.padding([6, 16]);
|
||||
|
||||
column![rebuild_btns, open]
|
||||
let install_cli = button(text(t(locale, "settings.installCli")).size(13))
|
||||
.on_press(Message::Settings(SettingsMsg::InstallCli))
|
||||
.style(inputs::secondary_button)
|
||||
.padding([6, 16]);
|
||||
|
||||
column![rebuild_btns, row![open, install_cli].spacing(8)]
|
||||
.spacing(12)
|
||||
.padding([0, 16])
|
||||
.into()
|
||||
|
||||
Reference in New Issue
Block a user