Skip to content

Commit

Permalink
refactor: simplify impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Sep 26, 2023
1 parent c80b2a2 commit f756117
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/infra/infer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// Use this to infer type for val, as same as type ascription
pub const fn infer<T>(val: T) -> T {
val
}
1 change: 1 addition & 0 deletions src/infra/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod fp;
pub mod http;
pub mod infer;
pub mod iter;
pub mod json;
pub mod option;
Expand Down
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ use crate::api::user::User;
use crate::args::parser::no_operation;
use crate::args::{parser, Args};
use crate::infra::fp::currying::eq;
use crate::infra::infer::infer;
use crate::infra::iter::IntoIteratorExt;
use crate::infra::option::OptionExt;
use crate::infra::result::IntoResult;
use anyhow::Result;
use clap::CommandFactory;
use clap::Parser;
use clap::{Command, CommandFactory};
use colored::Colorize;
use std::env;

Expand Down Expand Up @@ -164,10 +165,8 @@ async fn main() -> Result<()> {
display::list_news(style, time_style, &news_vec, rev)?
}

_ if no_operation(&args) => {
Args::command().print_help()?;
return ().into_ok();
}
_ if no_operation(&args) =>
infer::<Command>(Args::command()).render_help().to_string(),
_ => "Invalid usage, follow '--help' for more information".to_owned()
};

Expand Down

0 comments on commit f756117

Please sign in to comment.