Skip to content

Commit

Permalink
Merge pull request #12 from rruckley/feat-module-tmf674-6
Browse files Browse the repository at this point in the history
feat: Module TMF674
  • Loading branch information
rruckley authored Jan 21, 2025
2 parents b865006 + 0aae318 commit 5edc1dd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ use tmf::tmf648::{
TMF648Modules,
handle_tmf648,
};
use tmf::tmf674::{
TMF674Modules,
handle_tmf674,
};

#[derive(Parser,Debug)]
#[command(version, about = "CLI tool for interacting with TMF APIs", author = "Ryan Ruckley")]
Expand Down Expand Up @@ -69,6 +73,10 @@ pub enum TMFModules {
TMF648 {
#[command(subcommand, help = "Product Quote")]
module : TMF648Modules,
},
TMF674 {
#[command(subcommand, help = "Geographic Site")]
module : TMF674Modules,
}
}

Expand Down Expand Up @@ -117,6 +125,9 @@ fn main() -> Result<(),TMFError> {
},
TMFModules::TMF648 { module } => {
handle_tmf648(&mut client, module, Some(opts))
},
TMFModules::TMF674 { module } => {
handle_tmf674(&mut client, module, Some(opts))
}
}
}
1 change: 1 addition & 0 deletions src/tmf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod tmf622;
pub mod tmf629;
pub mod tmf632;
pub mod tmf648;
pub mod tmf674;

#[derive(Clone, Subcommand, Debug)]
pub enum TMFOperation {
Expand Down
47 changes: 47 additions & 0 deletions src/tmf/tmf674.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//! TMF674 CLI Module
use clap::Subcommand;

use super::{
display_name,
display_opt,
iterate_name,
TMFOperation
};

use tmf_client::common::tmf_error::TMFError;
use tmf_client::{Operations, QueryOptions, TMFClient};

#[derive(Subcommand, Clone, Debug)]
pub enum TMF674Modules {
Site {
#[command(subcommand, help = "Geographic Site")]
op : TMFOperation
},
}

pub fn handle_tmf674(client : &mut TMFClient, module : TMF674Modules, opts : Option<QueryOptions>) -> Result<(),TMFError> {
match module {
TMF674Modules::Site { op } => {
match op {
TMFOperation::List => {
let sites = client.tmf674().site().list(opts)?;
iterate_name(&sites);
Ok(())
},
TMFOperation::Get { id } => {
let site = client.tmf674().site().get(id)?;
let the_first = site.first().unwrap();
display_name(the_first);
display_opt("Description", &the_first.description);
display_opt("Code",&the_first.code);
display_opt("Status", &the_first.status);
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
}
}

0 comments on commit 5edc1dd

Please sign in to comment.