MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / remove

Function remove

cli/src/pkg.rs:111–130  ·  view source on GitHub ↗
(path: &Path, pkgs: &[String])

Source from the content-addressed store, hash-verified

109}
110
111pub fn remove(path: &Path, pkgs: &[String]) -> Result<()> {
112 if pkgs.is_empty() {
113 bail!("nothing to remove: pass one or more package names");
114 }
115 let mut m = Manifest::load(path)?;
116 let names: Vec<&str> = pkgs.iter().map(|s| parse_spec(s).0).collect();
117 // Validate every name exists first so a single bad one aborts before any write or print.
118 for name in &names {
119 if !m.imports.contains_key(*name) && !m.host.contains_key(*name) {
120 bail!("'{name}' is not in {}", path.display());
121 }
122 }
123 for name in names {
124 let _ = m.imports.remove(name).is_some() | m.host.remove(name).is_some();
125 ui::removed(name);
126 }
127 m.save(path)?;
128 ui::note("updated packages.json");
129 Ok(())
130}
131
132/// Parse `name` or `name=url`.
133fn parse_spec(spec: &str) -> (&str, Option<String>) {

Callers 1

mainFunction · 0.70

Calls 10

loadFunction · 0.85
removedFunction · 0.85
noteFunction · 0.85
collectMethod · 0.80
contains_keyMethod · 0.80
removeMethod · 0.80
saveMethod · 0.80
parse_specFunction · 0.70
is_emptyMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected