brewlog/src/presentation/cli/gear.rs
Jon Seager 74a8bef475
feat(web): add Gear web UI with reactive updates
Implement complete web interface for the Gear entity:
- Add GearView model with category badges and formatted display
- Create GearTemplate and GearListTemplate for Askama rendering
- Build main gear page with collapsible add form (Datastar-powered)
- Implement gear list table with sortable columns and pagination
- Use trash icon for delete actions matching roasts table design
- Add Gear navigation link in main menu between Bags and Timeline
- Integrate gear events into timeline view with proper labels and links

The web UI follows the established patterns from other entities with
Datastar for reactive fragment updates and proper authentication gating.

Apply code formatting fixes across all gear-related modules.
2026-02-02 15:35:57 +00:00

72 lines
1.7 KiB
Rust

use anyhow::Result;
use clap::Args;
use super::macros::{define_delete_command, define_get_command};
use super::print_json;
use crate::domain::ids::GearId;
use crate::infrastructure::client::BrewlogClient;
#[derive(Debug, Args)]
pub struct AddGearCommand {
#[arg(long)]
pub category: String,
#[arg(long)]
pub make: String,
#[arg(long)]
pub model: String,
#[arg(long)]
pub notes: Option<String>,
}
pub async fn add_gear(client: &BrewlogClient, command: AddGearCommand) -> Result<()> {
let gear = client
.gear()
.create(
&command.category,
command.make,
command.model,
command.notes,
)
.await?;
print_json(&gear)
}
#[derive(Debug, Args)]
pub struct ListGearCommand {
#[arg(long)]
pub category: Option<String>,
}
pub async fn list_gear(client: &BrewlogClient, command: ListGearCommand) -> Result<()> {
let gear = client.gear().list(command.category).await?;
print_json(&gear)
}
define_get_command!(GetGearCommand, get_gear, GearId, gear);
#[derive(Debug, Args)]
pub struct UpdateGearCommand {
#[arg(long)]
pub id: i64,
#[arg(long)]
pub make: Option<String>,
#[arg(long)]
pub model: Option<String>,
#[arg(long)]
pub notes: Option<String>,
}
pub async fn update_gear(client: &BrewlogClient, command: UpdateGearCommand) -> Result<()> {
let gear = client
.gear()
.update(
GearId::new(command.id),
command.make,
command.model,
command.notes,
)
.await?;
print_json(&gear)
}
define_delete_command!(DeleteGearCommand, delete_gear, GearId, gear, "gear");