Skip to content

Commit 4fbf872

Browse files
authored
Merge pull request #2821 from ThorstenHans/feature/plugins-inspect
Adding the `spin plugins inspect` command
2 parents 6f010fa + 0a65d14 commit 4fbf872

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/commands/plugins.rs

+36
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ pub enum PluginCommands {
3939

4040
/// Fetch the latest Spin plugins from the spin-plugins repository.
4141
Update,
42+
43+
/// Print information about a plugin.
44+
Show(Show),
4245
}
4346

4447
impl PluginCommands {
@@ -50,6 +53,7 @@ impl PluginCommands {
5053
PluginCommands::Uninstall(cmd) => cmd.run().await,
5154
PluginCommands::Upgrade(cmd) => cmd.run().await,
5255
PluginCommands::Update => update().await,
56+
PluginCommands::Show(cmd) => cmd.run().await,
5357
}
5458
}
5559
}
@@ -416,6 +420,38 @@ impl Upgrade {
416420
}
417421
}
418422

423+
#[derive(Parser, Debug)]
424+
pub struct Show {
425+
/// Name of Spin plugin.
426+
pub name: String,
427+
}
428+
429+
impl Show {
430+
pub async fn run(self) -> Result<()> {
431+
let manager = PluginManager::try_default()?;
432+
let manifest = manager
433+
.get_manifest(
434+
&ManifestLocation::PluginsRepository(PluginLookup::new(&self.name, None)),
435+
false,
436+
SPIN_VERSION,
437+
)
438+
.await?;
439+
440+
println!(
441+
"{}: {} (License: {})\n{}\n{}",
442+
manifest.name(),
443+
manifest.version(),
444+
manifest.license(),
445+
manifest
446+
.homepage_url()
447+
.map(|u| format!("{u}\n"))
448+
.unwrap_or_default(),
449+
manifest.description().unwrap_or("No description provided"),
450+
);
451+
Ok(())
452+
}
453+
}
454+
419455
fn is_potential_upgrade(current: &PluginManifest, candidate: &PluginManifest) -> bool {
420456
match (current.try_version(), candidate.try_version()) {
421457
(Ok(cur_ver), Ok(cand_ver)) => cand_ver > cur_ver,

0 commit comments

Comments
 (0)