pub struct Opts {
pub api: OptsApi,
pub task: String,
pub full: bool,
pub filter: Vec<String>,
pub args: Vec<String>,
pub command: Vec<String>,
}
Expand description
§e-app
Fields§
§api: OptsApi
API接口
task: String
任务
full: bool
是否完整信息
filter: Vec<String>
筛选排除
args: Vec<String>
扩展参数
command: Vec<String>
扩展指令
Implementations§
Source§impl Opts
impl Opts
Sourcepub fn new<I>(args: Option<I>) -> AnyResult<Self>
pub fn new<I>(args: Option<I>) -> AnyResult<Self>
§Example
#[tokio::main]
async fn main() -> e_utils::AnyResult<()> {
use e_utils::cmd::CmdResult;
use hw::cli::api;
use hw::cli::Opts;
use serde_json::Value;
let opts = Opts::new(None as Option<Vec<&str>>)?;
let mut res: CmdResult<Value> = CmdResult {
content: String::new(),
status: false,
opts: Value::Null,
};
match api(opts, &mut res.opts).await {
Ok(v) => {
res.content = v;
res.status = true;
}
Err(e) => res.content = e.to_string(),
}
println!("\n{}", res.to_str()?);
Ok(())
}
Sourcepub fn check_empty() -> bool
pub fn check_empty() -> bool
§检查空
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Opts
impl<'de> Deserialize<'de> for Opts
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl StructOpt for Opts
impl StructOpt for Opts
Source§fn from_clap(matches: &ArgMatches<'_>) -> Self
fn from_clap(matches: &ArgMatches<'_>) -> Self
Builds the struct from
clap::ArgMatches
. It’s guaranteed to succeed
if matches
originates from an App
generated by StructOpt::clap
called on
the same type, otherwise it must panic.Source§fn from_args() -> Selfwhere
Self: Sized,
fn from_args() -> Selfwhere
Self: Sized,
Builds the struct from the command line arguments (
std::env::args_os
).
Calls clap::Error::exit
on failure, printing the error message and aborting the program.Source§fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
Builds the struct from the command line arguments (
std::env::args_os
).
Unlike StructOpt::from_args
, returns clap::Error
on failure instead of aborting the program,
so calling .exit
is up to you.Source§fn from_iter<I>(iter: I) -> Self
fn from_iter<I>(iter: I) -> Self
Gets the struct from any iterator such as a
Vec
of your making.
Print the error message and quit the program in case of failure. Read moreAuto Trait Implementations§
impl Freeze for Opts
impl RefUnwindSafe for Opts
impl Send for Opts
impl Sync for Opts
impl Unpin for Opts
impl UnwindSafe for Opts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more