aboutsummaryrefslogtreecommitdiffstats
path: root/crates/rocie-cli/src
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:30:25 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:30:25 +0100
commitf7869a09906747d0797dcd8c49c069fa8f02930c (patch)
treef219226e62d16995cd4906d57f7e279b591460ff /crates/rocie-cli/src
parentstyle(treewide): Format (diff)
downloadserver-f7869a09906747d0797dcd8c49c069fa8f02930c.zip
chore(treewide): Remove last references to old paths
Diffstat (limited to '')
-rw-r--r--crates/rocie-cli/src/cli.rs12
-rw-r--r--crates/rocie-cli/src/handle/mod.rs41
-rw-r--r--crates/rocie-cli/src/main.rs9
3 files changed, 40 insertions, 22 deletions
diff --git a/crates/rocie-cli/src/cli.rs b/crates/rocie-cli/src/cli.rs
index 626a7b1..376eda5 100644
--- a/crates/rocie-cli/src/cli.rs
+++ b/crates/rocie-cli/src/cli.rs
@@ -15,6 +15,12 @@ pub(crate) enum Command {
command: ProductCommand,
},
+ /// Deal with users
+ User {
+ #[command(subcommand)]
+ command: UserCommand,
+ },
+
/// Deal with parents
Parents {
#[command(subcommand)]
@@ -41,6 +47,12 @@ pub(crate) enum Command {
}
#[derive(Subcommand)]
+pub(crate) enum UserCommand {
+ /// List all registered users
+ List {},
+}
+
+#[derive(Subcommand)]
pub(crate) enum ProductParentCommand {
/// Register a new product parent
Register {
diff --git a/crates/rocie-cli/src/handle/mod.rs b/crates/rocie-cli/src/handle/mod.rs
index 4e63696..4e30f77 100644
--- a/crates/rocie-cli/src/handle/mod.rs
+++ b/crates/rocie-cli/src/handle/mod.rs
@@ -1,16 +1,17 @@
-use crate::cli::{BarcodeCommand, ProductCommand, UnitCommand, UnitPropertyCommand};
+use crate::cli::{BarcodeCommand, ProductCommand, UnitCommand, UnitPropertyCommand, UserCommand};
use anyhow::{Context, Result};
use rocie_client::{
apis::{
- api_get_inventory_api::amount_by_id,
- api_get_product_api::{product_by_id, products_registered},
- api_get_unit_api::{unit_by_id, units},
- api_get_unit_property_api::{unit_properties, unit_property_by_id},
- api_set_barcode_api::{buy_barcode, consume_barcode},
- api_set_product_api::{associate_barcode, register_product},
- api_set_unit_api::register_unit,
- api_set_unit_property_api::register_unit_property,
+ api_get_auth_inventory_api::amount_by_id,
+ api_get_auth_product_api::{product_by_id, products_registered},
+ api_get_auth_unit_api::{unit_by_id, units},
+ api_get_auth_unit_property_api::{unit_properties, unit_property_by_id},
+ api_get_auth_user_api::users,
+ api_set_auth_barcode_api::{buy_barcode, consume_barcode},
+ api_set_auth_product_api::{associate_barcode, register_product},
+ api_set_auth_unit_api::register_unit,
+ api_set_auth_unit_property_api::register_unit_property,
configuration::Configuration,
},
models::{
@@ -19,6 +20,16 @@ use rocie_client::{
},
};
+pub(crate) async fn user(config: &Configuration, command: UserCommand) -> Result<()> {
+ match command {
+ UserCommand::List {} => {
+ users(config).await?;
+ }
+ }
+
+ Ok(())
+}
+
#[expect(clippy::too_many_lines)]
pub(crate) async fn product(config: &Configuration, command: ProductCommand) -> Result<()> {
match command {
@@ -227,15 +238,9 @@ pub(crate) async fn unit_property(
) -> Result<()> {
match command {
UnitPropertyCommand::Register { name, description } => {
- let new_id = register_unit_property(
- config,
- UnitPropertyStub {
- description,
- name,
- },
- )
- .await
- .context("Failed to register unit property")?;
+ let new_id = register_unit_property(config, UnitPropertyStub { description, name })
+ .await
+ .context("Failed to register unit property")?;
println!("Registered new unit property with id: {new_id}");
}
UnitPropertyCommand::List {} => {
diff --git a/crates/rocie-cli/src/main.rs b/crates/rocie-cli/src/main.rs
index 2a4eaac..0b3ec09 100644
--- a/crates/rocie-cli/src/main.rs
+++ b/crates/rocie-cli/src/main.rs
@@ -15,11 +15,12 @@ async fn main() -> Result<()> {
"http://127.0.0.1:8080".clone_into(&mut config.base_path);
match args.command {
- Command::Product{command}=>handle::product(&config,command).await?,
- Command::Unit{command}=>handle::unit(&config,command).await?,
- Command::Barcode{command}=>handle::barcode(&config,command).await?,
- Command::UnitProperty{command}=>handle::unit_property(&config,command).await?,
+ Command::Product { command } => handle::product(&config, command).await?,
+ Command::Unit { command } => handle::unit(&config, command).await?,
+ Command::Barcode { command } => handle::barcode(&config, command).await?,
+ Command::UnitProperty { command } => handle::unit_property(&config, command).await?,
Command::Parents { command } => todo!(),
+ Command::User { command } => handle::user(&config, command).await?,
}
Ok(())