use std::{ error::Error, io::{self, Read}, }; use clap::{Args, Parser}; mod args; use mqi::{ prelude::*, connect_options::ApplName, core::values::{MQENC, MQOO}, headers::TextEnc, mqstr, open_options::ObjectString, sys, types::{MessageFormat, ObjectName, QueueName}, MqStr, Object, QueueManager, }; use tracing::Level; const APP_NAME: ApplName = ApplName(mqstr!("open_put")); #[derive(Parser, Debug)] struct Cli { #[command(flatten)] connection: args::ConnectionArgs, #[arg(long)] format: Option, #[command(flatten)] target: Target, } #[derive(Args, Debug)] #[group(required = true, multiple = false)] struct Target { #[arg(short, long)] topic: Option, #[arg(short, long)] queue: Option, } fn main() -> Result<(), Box> { let subscriber = tracing_subscriber::fmt().compact().with_max_level(Level::DEBUG).finish(); tracing::subscriber::set_global_default(subscriber)?; let args = Cli::parse(); let client_definition = args.connection.client_definition()?; let qm_name = args.connection.queue_manager_name()?; let creds = args.connection.credentials(); // It will be either queue or topic but not both let (queue, topic) = ( args.target .queue .as_deref() .map(ObjectName::try_from) .transpose()? // Option -> Result