use failure::Error;
fn main() -> Result<(), Error> {
let tmp_dir = tempfile::tempdir().unwrap();
let index_path = tmp_dir.path().join("index");
let project = tmp_dir.path().join("foo");
let status = std::process::Command::new("cargo")
.args(&["new", project.to_str().unwrap()])
.status()?;
assert!(status.success());
let status = std::process::Command::new("cargo")
.args(&["package", "--allow-dirty"])
.current_dir(&project)
.status()?;
assert!(status.success());
let manifest_path = project.join("Cargo.toml");
reg_index::init(&index_path, "https://example.com", None)?;
reg_index::add(
&index_path,
"https://example.com",
Some(&manifest_path),
None,
None,
)?;
let pkgs = reg_index::list(&index_path, "foo", None)?;
println!("{}", serde_json::to_string(&pkgs[0])?);
Ok(())
}