8000 Feat: module tmf622 by rruckley · Pull Request #7 · rruckley/tmf-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat: module tmf622 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 20, 2025
8000
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tmf-cli"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
13 changes: 12 additions & 1 deletion src/main.rs
10000
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use tmf::tmf620::{
TMF620Modules,
handle_tmf620,
};
use tmf::tmf622::{
TMF622Modules,
handle_tmf622,
};

#[derive(Parser,Debug)]
#[command(version, about = "CLI tool for interacting with TMF APIs", author = "Ryan Ruckley")]
Expand Down Expand Up @@ -37,6 +41,10 @@ pub enum TMFModules {
TMF620 {
#[command(subcommand, help = "Product Catalog")]
module : TMF620Modules,
},
TMF622 {
#[command(subcommand, help = "Product Order")]
module : TMF622Modules,
}
}

Expand Down Expand Up @@ -73,6 +81,9 @@ fn main() -> Result<(),TMFError> {
match args.tmf {
TMFModules::TMF620 { module } => {
handle_tmf620(&mut client, module, Some(opts))
}
},
TMFModules::TMF622 { module } => {
handle_tmf622(&mut client, module, Some(opts))
},
}
}
5 changes: 3 additions & 2 deletions src/tmf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use tmflib::{
};

pub mod tmf620;
pub mod tmf622;

#[derive(Clone, Subcommand, Debug)]
pub enum TMFOperation {
Expand Down Expand Up @@ -42,7 +43,7 @@ pub fn display_name<T: HasId + HasName>(item : &T) {

}

pub fn display_desc<T : HasId + HasName + HasDescription>(item : &T) {
display_name(item);
pub fn display_desc<T : HasId + HasDescription>(item : &T) {
display_id(item);
println!("Desc:\t{}",item.get_description());
}
2 changes: 1 addition & 1 deletion src/tmf/tmf620.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Handle TMF620 operations
//! TMF620 CLI Module

use clap::Subcommand;

Expand Down
42 changes: 42 additions & 0 deletions src/tmf/tmf622.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//! TMF622 CLI Module
//!

use clap::Subcommand;

use super::{
display_desc, iterate_desc, TMFOperation
};

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

#[derive(Subcommand, Clone, Debug)]
pub enum TMF622Modules {
Order {
#[command(subcommand, help = "ProductOrder")]
op : TMFOperation
},
}

pub fn handle_tmf622(client : &mut TMFClient, module : TMF622Modules, opts : Option<QueryOptions>) -> Result<(),TMFError> {
match module {
TMF622Modules::Order { op } => {
match op {
TMFOperation::List => {
let orders = client.tmf622().order().list(opts)?;
iterate_desc(&orders);
Ok(())
},
TMFOperation::Get { id } => {
let order = client.tmf622().order().get(id)?;
let the_first = order.first().unwrap();
display_desc(the_first);
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
}
}
Loading
0