Finishes debug and most plumbing
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good
Details
Build Successful The build was successful
Gitea/epoch_forge/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d4a88f402f
commit
7b321e4568
|
|
@ -12,8 +12,8 @@ pub mod entity_generic;
|
|||
pub mod epoch;
|
||||
pub mod generate;
|
||||
pub mod init;
|
||||
// pub mod roll;
|
||||
pub mod show;
|
||||
pub mod status;
|
||||
// pub mod diff;
|
||||
// pub mod utils;
|
||||
// pub mod event;
|
||||
// pub mod town;
|
||||
|
|
|
|||
|
|
@ -44,12 +44,11 @@ use crate::{
|
|||
success::{SuccessMessages, display_success},
|
||||
};
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
|
||||
/// Arguments for the `init` subcommand.
|
||||
///
|
||||
/// The `--force` flag forces initialisation even when the target
|
||||
/// directory already contains files.
|
||||
#[derive(Args, Debug)]
|
||||
pub struct InitCmd {
|
||||
/// Force initialisation even if the directory isn't empty
|
||||
#[arg(long)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
//! A very succint status display
|
||||
|
||||
use clap::Args;
|
||||
use colored::Colorize;
|
||||
use lib_efo::epoch::{EpochConfig, EpochId};
|
||||
|
||||
/// Arguments for the `status` subcommand.
|
||||
#[derive(Args, Debug)]
|
||||
pub struct StatusCmd {
|
||||
/// An optionnal EpochId showing another epoch
|
||||
custom_id: Option<EpochId>,
|
||||
}
|
||||
|
||||
/// Print a short status
|
||||
pub(crate) fn status(cmd: &StatusCmd) -> Result<(), crate::error::AppError> {
|
||||
let mut main_epoch = EpochConfig::new_from_path(None)?;
|
||||
|
||||
let current_epoch = if let Some(epoch_id) = cmd.custom_id {
|
||||
main_epoch.try_load(&epoch_id)?;
|
||||
unsafe { main_epoch.try_load_id(epoch_id)? }
|
||||
} else {
|
||||
main_epoch.try_load_current()?
|
||||
};
|
||||
|
||||
let mut out = String::new();
|
||||
|
||||
out.push_str(
|
||||
&format!(
|
||||
"[{}{} {}]\n",
|
||||
" ".bright_blue(),
|
||||
"Epoch".blue(),
|
||||
current_epoch.epoch_id
|
||||
)
|
||||
.blue(),
|
||||
);
|
||||
|
||||
if !current_epoch.summary.is_empty() {
|
||||
out.push_str(&format!(
|
||||
" ├─ {:12} {}\n",
|
||||
"Summary".green(),
|
||||
current_epoch.summary
|
||||
));
|
||||
}
|
||||
if !current_epoch.tags.is_empty() {
|
||||
out.push_str(&format!(
|
||||
" ├─ {:12} {}\n",
|
||||
"Tags".green(),
|
||||
current_epoch.tags.join(",")
|
||||
));
|
||||
}
|
||||
out.push_str(&format!(" └─ {}\n", "Stats".green()));
|
||||
out.push_str(&format!(
|
||||
" ├ {:11} {}\n",
|
||||
"Events".bright_green(),
|
||||
current_epoch.events.len()
|
||||
));
|
||||
out.push_str(&format!(
|
||||
" ├ {:11} {}\n",
|
||||
"Characters".bright_green(),
|
||||
current_epoch.characters.len()
|
||||
));
|
||||
out.push_str(&format!(
|
||||
" ├ {:11} {}\n",
|
||||
"Towns".bright_green(),
|
||||
current_epoch.towns.len()
|
||||
));
|
||||
out.push_str(&format!(
|
||||
" └ {:11} {}",
|
||||
"Blockers".bright_green(),
|
||||
current_epoch.blockers.len()
|
||||
));
|
||||
println!("{}", out);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ use clap::{Parser, Subcommand};
|
|||
use crate::{
|
||||
commands::{
|
||||
entity_generic::EntitySubCommands, epoch::cli_epoch::EpochCmd, generate::GenCmd,
|
||||
init::InitCmd, show::ShowCmd,
|
||||
init::InitCmd, show::ShowCmd, status::StatusCmd,
|
||||
},
|
||||
error::AppError,
|
||||
};
|
||||
|
|
@ -62,6 +62,8 @@ struct Cli {
|
|||
enum TopLevelCmd {
|
||||
/// Initialise a new epoch folder.
|
||||
Init(InitCmd),
|
||||
/// Gives a very simple status.
|
||||
Status(StatusCmd),
|
||||
/// Advance or query the current epoch.
|
||||
#[command(subcommand)]
|
||||
Epoch(EpochCmd),
|
||||
|
|
@ -147,5 +149,6 @@ fn exec_dispatch(cli: Cli) -> Result<(), AppError> {
|
|||
&cmd,
|
||||
&lib_efo::stats::EntityType::Blocker,
|
||||
),
|
||||
TopLevelCmd::Status(cmd) => commands::status::status(&cmd),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ impl Entity {
|
|||
/// Adds a link (UUID) to the entity's metadata.
|
||||
///
|
||||
/// If `id_to_add` is already present in the `links` vector, this method does
|
||||
/// nothing – it silently ignores duplicates. The method is idempotent: calling
|
||||
/// nothing - it silently ignores duplicates. The method is idempotent: calling
|
||||
/// it repeatedly with the same UUID will not change the underlying state.
|
||||
pub fn add_to_links(&mut self, id_to_add: stats::TypedLink) {
|
||||
if !self.metadata.links.contains(&id_to_add) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
//! directories and are **not** part of this file.
|
||||
|
||||
use crate::epoch::{
|
||||
EpochId, EpochIdentifier, EpochInfo, MAIN_NAME, SUBFOLDER_NAMING, SaveMode,
|
||||
EpochId, EpochIdentifier, EpochInfo, MAIN_NAME, SUBFOLDER_NAMING, SaveMode, TagList,
|
||||
epoch_traits::ConfigWritable,
|
||||
};
|
||||
use std::{
|
||||
|
|
@ -307,6 +307,8 @@ impl EpochConfig {
|
|||
// New fake epoch
|
||||
let mut new_epoch = self.try_load_current()?.clone();
|
||||
new_epoch.epoch_id = self.epoch_id.next();
|
||||
new_epoch.summary = String::new();
|
||||
new_epoch.tags = TagList::new();
|
||||
Ok(new_epoch)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ impl EpochInfo {
|
|||
/// target entity is not found, an `EntityNotFoundById` error is returned.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `id_to_add_to` – The UUID of the entity that will receive the new link.
|
||||
/// * `e_type` – The type of the entity that should receive the link.
|
||||
/// * `id_to_add` – The UUID of the entity that should be linked.
|
||||
/// * `id_to_add_to` - The UUID of the entity that will receive the new link.
|
||||
/// * `e_type` - The type of the entity that should receive the link.
|
||||
/// * `id_to_add` - The UUID of the entity that should be linked.
|
||||
pub fn add_to_links(
|
||||
&mut self,
|
||||
id_to_add_to: Uuid,
|
||||
|
|
@ -185,7 +185,7 @@ impl EpochInfo {
|
|||
///
|
||||
/// The removal is performed on the *target* entity (`id_to_add_to`). If the
|
||||
/// target entity cannot be found, an `EpochError::EntityNotFoundById` error
|
||||
/// is returned. The removal itself is delegated to the entity’s
|
||||
/// is returned. The removal itself is delegated to the entity's
|
||||
/// `del_from_links` method, which silently ignores missing links.
|
||||
pub fn del_from_links(
|
||||
&mut self,
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ thin_newtype!(FactionId, usize, derives: [Add, Sub]);
|
|||
#[derive(Copy, Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Display, Default)]
|
||||
/// A typed link between two entities.
|
||||
///
|
||||
/// A link is a lightweight association that ties an entity’s **identifier**
|
||||
/// A link is a lightweight association that ties an entity's **identifier**
|
||||
/// (`id`) to a *semantic role* (`role`). The role is expressed by the
|
||||
/// [`Role`] enum and defines what the link actually means in the
|
||||
/// domain model.
|
||||
|
|
@ -604,7 +604,7 @@ pub struct TypedLink {
|
|||
/// The UUID of the entity that is linked.
|
||||
///
|
||||
/// The link is *unidirectional*; the `TypedLink` itself does not
|
||||
/// keep a back‑reference to the source entity.
|
||||
/// keep a back-reference to the source entity.
|
||||
pub id: Uuid,
|
||||
/// The semantic role that this link plays.
|
||||
///
|
||||
|
|
@ -624,7 +624,7 @@ impl TypedLink {
|
|||
/// Semantic role of a link.
|
||||
///
|
||||
/// The role encodes *what the link represents* in the model. The
|
||||
/// variants are intentionally limited to the most common use‑cases,
|
||||
/// variants are intentionally limited to the most common use-cases,
|
||||
/// but the enum can be extended if the domain evolves.
|
||||
pub enum Role {
|
||||
/// The linked entity has governing authority over the link owner
|
||||
|
|
|
|||
Loading…
Reference in New Issue