pub struct Cli<T>where
T: Cluster,{ /* private fields */ }
Expand description
CLI parser
Implementations§
Source§impl<T> Cli<T>where
T: Cluster,
impl<T> Cli<T>where
T: Cluster,
Sourcepub async fn execute(&self) -> Result<(), TuiError>
pub async fn execute(&self) -> Result<(), TuiError>
Executes the CLI. The config will be loaded from the default config file.
Sourcepub async fn execute_with(
&self,
yozefu_config: YozefuConfig,
) -> Result<(), TuiError>
pub async fn execute_with( &self, yozefu_config: YozefuConfig, ) -> Result<(), TuiError>
Executes the CLI with a specified kafka config client
Sourcepub fn cluster(&self) -> Option<T>
pub fn cluster(&self) -> Option<T>
This function returns Some(T)
when the user starts the TUI.
Otherwise, for subcommands commands that such config
or new-filter
, it returns None
.
Examples found in repository?
examples/my_cli.rs (line 32)
29 pub fn kafka_client_config(&self) -> ClusterConfig {
30 let mut config = ClientConfig::new();
31 config.set_log_level(rdkafka::config::RDKafkaLogLevel::Emerg);
32 if let Some(cluster) = self.command.cluster() {
33 match cluster {
34 Cluster::Localhost => {
35 config.set("bootstrap.servers", "kafka.localhost.acme:9092".to_string())
36 }
37 Cluster::Test => {
38 config.set("bootstrap.servers", "kafka.test.acme:9092".to_string())
39 }
40 Cluster::Development => config.set(
41 "bootstrap.servers",
42 "kafka.development.acme:9092".to_string(),
43 ),
44 Cluster::Production => config.set(
45 "bootstrap.servers",
46 "kafka.production.acme:9092".to_string(),
47 ),
48 };
49 }
50
51 ClusterConfig {
52 url_template: None,
53 schema_registry: None,
54 kafka: IndexMap::from_iter(config.config_map().clone()),
55 }
56 }
pub fn is_main_command(&self) -> bool
Trait Implementations§
Source§impl<T> Args for Cli<T>where
T: Cluster,
impl<T> Args for Cli<T>where
T: Cluster,
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Append to
Command
so it can instantiate self
via
FromArgMatches::update_from_arg_matches_mut
Read moreSource§impl<T> CommandFactory for Cli<T>where
T: Cluster,
impl<T> CommandFactory for Cli<T>where
T: Cluster,
Source§impl<T> FromArgMatches for Cli<T>where
T: Cluster,
impl<T> FromArgMatches for Cli<T>where
T: Cluster,
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Source§impl<T> Parser for Cli<T>where
T: Cluster,
impl<T> Parser for Cli<T>where
T: Cluster,
Source§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
Parse from iterator, exit on error.
Source§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
Parse from iterator, return Err on error.
Source§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
Auto Trait Implementations§
impl<T> Freeze for Cli<T>where
T: Freeze,
impl<T> RefUnwindSafe for Cli<T>where
T: RefUnwindSafe,
impl<T> Send for Cli<T>
impl<T> Sync for Cli<T>
impl<T> Unpin for Cli<T>where
T: Unpin,
impl<T> UnwindSafe for Cli<T>where
T: UnwindSafe,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self
file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self
file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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