Skip to content

Commit

Permalink
refactor(shapes): rename shape_action to view
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Nov 24, 2023
1 parent 64f52e4 commit 551b30b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 24 deletions.
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
mod cli;
use cli::{Commands, CLI};

mod shapes;
use shapes::*;

use clap::Parser;
use cli::{Commands, CLI};
use shapes::*;

fn main() {
let cli = CLI::parse();

match &cli.command {
Some(Commands::Square(square::Command { base, height })) => {
square::square_action(*base, *height)
}
Some(Commands::Circle(circle::Command { radius })) => circle::circle_action(*radius),
Some(Commands::Square(square::Command { base, height })) => square::view(*base, *height),
Some(Commands::Circle(circle::Command { radius })) => circle::view(*radius),
Some(Commands::Triangle(triangle::Command {
base,
height,
side_a,
side_b,
side_c,
})) => triangle::triangle_actions(*base, *height, *side_a, *side_b, *side_c),
})) => triangle::view(*base, *height, *side_a, *side_b, *side_c),
Some(Commands::Trapezoid(trapezoid::Command {
l_base,
s_base,
height,
})) => trapezoid::trapezoid_actions(*s_base, *l_base, *height),
})) => trapezoid::view(*s_base, *l_base, *height),
Some(Commands::Rhombus(rhombus::Command {
l_diagonal,
s_diagonal,
})) => rhombus::rhombus_actions(*s_diagonal, *l_diagonal),
})) => rhombus::view(*s_diagonal, *l_diagonal),
None => {}
}
}
4 changes: 2 additions & 2 deletions src/shapes/circle/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod action;
pub use action::circle_action;
mod view;
pub use view::view;

mod command;
pub use command::Command;
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/circle/action.rs → src/shapes/circle/view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::shapes::circle::Circle;

pub fn circle_action(radius: f64) {
pub fn view(radius: f64) {
let circle = Circle { radius };

println!("{}cm", circle.get_area());
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/rhombus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub use command::Command;
mod structs;
pub use structs::Rhombus;

mod action;
pub use action::rhombus_actions;
mod view;
pub use view::view;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::shapes::rhombus::Rhombus;

pub fn rhombus_actions(s_diagonal: f32, l_diagonal: f32) {
pub fn view(s_diagonal: f32, l_diagonal: f32) {
let rhombus = Rhombus {
l_diagonal,
s_diagonal,
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/square/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub use command::Command;
mod structs;
pub use structs::Square;

mod action;
pub use action::square_action;
mod view;
pub use view::view;
2 changes: 1 addition & 1 deletion src/shapes/square/action.rs → src/shapes/square/view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::shapes::square::Square;

pub fn square_action(base: i32, height: i32) {
pub fn view(base: i32, height: i32) {
let square = Square { base, height };

println!("{}cm", square.get_area());
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/trapezoid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub use command::Command;
mod structs;
pub use structs::Trapezoid;

mod action;
pub use action::trapezoid_actions;
mod view;
pub use view::view;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::shapes::trapezoid::Trapezoid;

pub fn trapezoid_actions(s_base: f32, l_base: f32, height: f32) {
pub fn view(s_base: f32, l_base: f32, height: f32) {
let trapezoid = Trapezoid {
height,
l_base,
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub use structs::{SidesTriangle, SimpleTriangle};
mod command;
pub use command::Command;

mod action;
pub use action::triangle_actions;
mod view;
pub use view::view;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::shapes::triangle::{SidesTriangle, SimpleTriangle};

pub fn triangle_actions(
pub fn view(
base: Option<f32>,
height: Option<f32>,

Expand Down

0 comments on commit 551b30b

Please sign in to comment.