XDGZ4V2QR277U7XYD7V7LRVDPGF4CYWNHCL5RFW3AKAMDEEBASEAC let mut installed = utils::get_installed(ctx.config.mod_dir())?;
let mut installed = if let ManageMode::Client = ctx.config.mode {utils::get_installed(ctx.config.mod_dir())} else if let Some(c) = ctx.cluster.as_ref() {let mut chain = LocalIndex::new();for e in c.members.values() {chain.mods.extend(utils::get_installed(e)?.mods);}debug!("Chained clustered mods: {:#?}", chain);Ok(chain)} else {Err(anyhow!("Failed to get clustered mods"))}?;
use std::fs;use crate::{api::model::Cluster,core::config,core::{config::ManageMode, Ctx},};use anyhow::{Context, Result};pub(crate) fn new(ctx: &mut Ctx, name: Option<String>) -> Result<()> {let target = std::env::current_dir()?.join("cluster.ron");let cluster = Cluster::new(name.clone(), target.clone());let pretty = ron::ser::to_string_pretty(&cluster, ron::ser::PrettyConfig::new())?;fs::write(&target, &pretty).context("Unable to write cluster file")?;println!("Created cluster {}",if name.is_some() {name.as_ref().unwrap()} else {""});ctx.config.mode = ManageMode::Server;println!("Set management mode to server");config::save_config(ctx.dirs.config_dir(), &ctx.config)?;Ok(())}
mod add;mod list;mod new;mod remove;use std::path::PathBuf;use add::add;use anyhow::Result;use clap::Subcommand;use list::list;use new::new;use remove::remove;use crate::core::Ctx;#[derive(Subcommand)]pub(crate) enum WsCommands {///Create a new cluster#[clap(alias("n"))]New { name: Option<String> },///Add a folder to an existing cluster#[clap(alias("a"))]Add { name: String, path: PathBuf },///Remove a folder from a cluster#[clap(alias("r"))]Remove { name: String },///List the members of a cluster#[clap(alias("l"), alias("ls"))]List {},}///Handle cluster subcommandspub(crate) fn cluster(ctx: &mut Ctx, command: WsCommands) -> Result<()> {match command {WsCommands::New { name } => new(ctx, name),WsCommands::Add { name, path } => add(ctx, name, path),WsCommands::Remove { name } => remove(ctx, name),WsCommands::List {} => list(ctx),}}
use std::path::PathBuf;use anyhow::Result;use crate::core::Ctx;pub(super) fn add(ctx: &mut Ctx, name: String, path: PathBuf) -> Result<()> {if let Some(c) = &mut ctx.cluster {c.members.insert(name.clone(), path.canonicalize()?);c.save()?;println!("Added {}({}) to cluster {}",name,path.display(),if c.name.is_some() {c.name.as_ref().unwrap()} else {""});} else {println!("There is no cluster to add to!");}Ok(())}
}}}#[derive(Deserialize, Serialize, Debug, Clone)]pub struct Cluster {pub name: Option<String>,///K: Member Name V: Member Pathpub members: HashMap<String, PathBuf>,#[serde(skip)]path: PathBuf,}impl Cluster {pub fn new(name: Option<String>, path: PathBuf) -> Self {Cluster {name,members: HashMap::new(),path,}}pub fn find() -> Result<Option<Self>> {let has_cluster = |p: &Path| -> Result<Option<Self>> {for e in p.read_dir()?.flatten() {if e.file_name().as_os_str() == OsStr::new("cluster.ron") {let raw = fs::read_to_string(e.path())?;let mut clstr: Cluster = ron::from_str(&raw)?;clstr.path = e.path().to_path_buf();return Ok(Some(clstr));}}Ok(None)};let mut depth = 0;let mut target = std::env::current_dir()?;loop {debug!("Checking for cluster file in {}", target.display());let test = has_cluster(&target)?;if test.is_some() {break Ok(test);} else {if let Some(p) = target.parent() {target = p.to_owned();depth += 1;} else {break Ok(None);}}
/target/modsCargo.lock.pijul.ignore
name: Ruston:push:branches: [ "main" ]pull_request:branches: [ "main" ]env:CARGO_TERM_COLOR: alwaysjobs:build:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v3- name: Buildrun: cargo build --verbose- name: Run testsrun: cargo test --verbose
---name: Bug reportabout: Create a report to help us improvetitle: "[BUG]"labels: bugassignees: AnActualEmerald---**Describe the bug**A clear and concise description of what the bug is.**To Reproduce**Steps to reproduce the behavior:1. Run command `x` with args `y`**Expected behavior**A clear and concise description of what you expected to happen.**Logs**```Output of running the command with `papa -d````**Environment (please complete the following information):**- OS: [e.g. Ubuntu, Arch, Windows, etc.]- Version [e.g. 22]**Additional context**Add any other context about the problem here.