Improve dependency hygiene (#9360)
Signed-off-by: jh-block <jhugo@block.xyz>
This commit is contained in:
@@ -935,6 +935,7 @@ enum Command {
|
||||
},
|
||||
|
||||
/// Update the goose CLI version
|
||||
#[cfg(feature = "update")]
|
||||
#[command(about = "Update the goose CLI version")]
|
||||
Update {
|
||||
/// Update to canary version
|
||||
@@ -1269,6 +1270,7 @@ fn get_command_name(command: &Option<Command>) -> &'static str {
|
||||
Some(Command::Run { .. }) => "run",
|
||||
Some(Command::Gateway { .. }) => "gateway",
|
||||
Some(Command::Schedule { .. }) => "schedule",
|
||||
#[cfg(feature = "update")]
|
||||
Some(Command::Update { .. }) => "update",
|
||||
Some(Command::Recipe { .. }) => "recipe",
|
||||
Some(Command::Plugin { .. }) => "plugin",
|
||||
@@ -2099,6 +2101,7 @@ pub async fn cli() -> anyhow::Result<()> {
|
||||
}
|
||||
Some(Command::Gateway { command }) => handle_gateway_command(command).await,
|
||||
Some(Command::Schedule { command }) => handle_schedule_command(command).await,
|
||||
#[cfg(feature = "update")]
|
||||
Some(Command::Update {
|
||||
canary,
|
||||
reconfigure,
|
||||
|
||||
@@ -10,4 +10,5 @@ pub mod schedule;
|
||||
pub mod session;
|
||||
pub mod term;
|
||||
pub mod tui;
|
||||
#[cfg(feature = "update")]
|
||||
pub mod update;
|
||||
|
||||
@@ -3,8 +3,11 @@ use anyhow::{Context, Result};
|
||||
|
||||
use cliclack::{confirm, multiselect, select};
|
||||
use etcetera::home_dir;
|
||||
#[cfg(feature = "nostr")]
|
||||
use goose::config::Config;
|
||||
use goose::session::{generate_diagnostics, nostr_share, Session, SessionManager, SessionType};
|
||||
#[cfg(feature = "nostr")]
|
||||
use goose::session::nostr_share;
|
||||
use goose::session::{generate_diagnostics, Session, SessionManager, SessionType};
|
||||
use goose::utils::safe_truncate;
|
||||
use regex::Regex;
|
||||
use std::fs;
|
||||
@@ -218,7 +221,7 @@ pub async fn handle_session_export(
|
||||
output_path: Option<PathBuf>,
|
||||
format: String,
|
||||
nostr: bool,
|
||||
relays: Vec<String>,
|
||||
#[cfg_attr(not(feature = "nostr"), allow(unused_variables))] relays: Vec<String>,
|
||||
) -> Result<()> {
|
||||
let session_manager = SessionManager::instance();
|
||||
let session = match session_manager.get_session(&session_id, true).await {
|
||||
@@ -244,6 +247,7 @@ pub async fn handle_session_export(
|
||||
_ => return Err(anyhow::anyhow!("Unsupported format: {}", format)),
|
||||
};
|
||||
|
||||
#[cfg(feature = "nostr")]
|
||||
if nostr {
|
||||
if format != "json" {
|
||||
return Err(anyhow::anyhow!(
|
||||
@@ -266,6 +270,10 @@ pub async fn handle_session_export(
|
||||
println!("{}", share.deeplink);
|
||||
return Ok(());
|
||||
}
|
||||
#[cfg(not(feature = "nostr"))]
|
||||
if nostr {
|
||||
return Err(anyhow::anyhow!("goose was not built with nostr support"));
|
||||
}
|
||||
|
||||
if let Some(output_path) = output_path {
|
||||
fs::write(&output_path, output).with_context(|| {
|
||||
@@ -281,7 +289,12 @@ pub async fn handle_session_export(
|
||||
|
||||
pub async fn handle_session_import(input: String, nostr: bool) -> Result<()> {
|
||||
let json = if nostr || input.starts_with("goose://sessions/nostr") {
|
||||
nostr_share::import_session_json_from_deeplink(&input).await?
|
||||
#[cfg(feature = "nostr")]
|
||||
{
|
||||
nostr_share::import_session_json_from_deeplink(&input).await?
|
||||
}
|
||||
#[cfg(not(feature = "nostr"))]
|
||||
return Err(anyhow::anyhow!("goose was not built with nostr support"));
|
||||
} else {
|
||||
fs::read_to_string(&input)
|
||||
.with_context(|| format!("Failed to read session import file: {input}"))?
|
||||
|
||||
Reference in New Issue
Block a user