mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
better devtools
This commit is contained in:
committed by
Aiden McClelland
parent
c413814ac4
commit
1d97856922
@@ -1,4 +1,5 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
||||
use color_eyre::eyre::eyre;
|
||||
@@ -137,6 +138,26 @@ pub enum MatchError {
|
||||
ListUniquenessViolation,
|
||||
}
|
||||
|
||||
#[command(rename = "config-spec", cli_only, blocking, display(display_none))]
|
||||
pub fn verify_spec(#[arg] path: PathBuf) -> Result<(), Error> {
|
||||
let mut file = std::fs::File::open(&path)?;
|
||||
let format = match path.extension().and_then(|s| s.to_str()) {
|
||||
Some("yaml") | Some("yml") => IoFormat::Yaml,
|
||||
Some("json") => IoFormat::Json,
|
||||
Some("toml") => IoFormat::Toml,
|
||||
Some("cbor") => IoFormat::Cbor,
|
||||
_ => {
|
||||
return Err(Error::new(
|
||||
eyre!("Unknown file format. Expected one of yaml, json, toml, cbor."),
|
||||
crate::ErrorKind::Deserialization,
|
||||
));
|
||||
}
|
||||
};
|
||||
let _: ConfigSpec = format.from_reader(&mut file)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command(subcommands(get, set))]
|
||||
pub fn config(#[arg] id: PackageId) -> Result<PackageId, Error> {
|
||||
Ok(id)
|
||||
|
||||
@@ -28,3 +28,8 @@ pub fn init(#[context] ctx: SdkContext) -> Result<(), Error> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command(subcommands(crate::s9pk::verify, crate::config::verify_spec))]
|
||||
pub fn verify() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -359,9 +359,8 @@ pub async fn sideload(
|
||||
}
|
||||
pde.save(&mut tx).await?;
|
||||
tx.commit(None).await?;
|
||||
drop(hdl);
|
||||
|
||||
download_install_s9pk(
|
||||
if let Err(e) = download_install_s9pk(
|
||||
&new_ctx,
|
||||
&manifest,
|
||||
None,
|
||||
@@ -377,7 +376,32 @@ pub async fn sideload(
|
||||
)
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
.await
|
||||
{
|
||||
let err_str = format!(
|
||||
"Install of {}@{} Failed: {}",
|
||||
manifest.id, manifest.version, e
|
||||
);
|
||||
tracing::error!("{}", err_str);
|
||||
tracing::debug!("{:?}", e);
|
||||
if let Err(e) = new_ctx
|
||||
.notification_manager
|
||||
.notify(
|
||||
&mut hdl,
|
||||
Some(manifest.id),
|
||||
NotificationLevel::Error,
|
||||
String::from("Install Failed"),
|
||||
err_str,
|
||||
(),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::error!("Failed to issue Notification: {}", e);
|
||||
tracing::debug!("{:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.body(Body::empty())
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn package() -> Result<(), RpcError> {
|
||||
#[command(subcommands(
|
||||
version::git_info,
|
||||
s9pk::pack,
|
||||
s9pk::verify,
|
||||
developer::verify,
|
||||
developer::init,
|
||||
inspect::inspect
|
||||
))]
|
||||
|
||||
@@ -107,7 +107,7 @@ pub fn pack(#[context] ctx: SdkContext, #[arg] path: Option<PathBuf>) -> Result<
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command(cli_only, display(display_none))]
|
||||
#[command(rename = "s9pk", cli_only, display(display_none))]
|
||||
pub async fn verify(#[arg] path: PathBuf) -> Result<(), Error> {
|
||||
let mut s9pk = S9pkReader::open(path, true).await?;
|
||||
s9pk.validate().await?;
|
||||
|
||||
Reference in New Issue
Block a user