pub struct Cli {
pub monitors: Vec<Monitor>,
pub backend: Option<String>,
pub needs_capabilities: bool,
pub dry_run: bool,
pub verbose: u8,
pub args: Vec<String>,
/* private fields */
}Expand description
A command line tool to change display monitors’ input sources via DDC/CI.
§Examples
fn run_cli(args: Vec<String>) -> anyhow::Result<()> {
let mut cli = Cli::new();
cli.args = args;
cli.run()
}To setup Cli from the command line arguments:
use clap::Parser;
use monitor_input::{Cli,Monitor};
fn main() -> anyhow::Result<()> {
let mut cli = Cli::parse();
cli.init_logger();
cli.monitors = Monitor::enumerate();
cli.run()
}See https://github.com/kojiishi/monitor-input-rs for more details.
Fields§
§monitors: Vec<Monitor>The list of Monitors to run the command line tool on.
This field is usually initialized to Monitor::enumerate().
backend: Option<String>Filter by the backend name.
needs_capabilities: boolGet capabilities from the display monitors.
dry_run: boolDry-run (prevent actual changes).
verbose: u8Show verbose information.
args: Vec<String>name to search,
name=input to change the input source,
or name=input1,input2 to toggle.
Implementations§
Source§impl Cli
impl Cli
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an instance with display monitors from Monitor::enumerate().
Sourcepub fn init_logger(&self)
👎Deprecated since 1.2.1: To remove loggers from the lib. Please setup your favorite logger.
pub fn init_logger(&self)
To remove loggers from the lib. Please setup your favorite logger.
Initialize the logging.
The configurations depend on Cli::verbose.
Trait Implementations§
Source§impl Args for Cli
impl Args for Cli
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 CommandFactory for Cli
impl CommandFactory for Cli
Source§impl FromArgMatches for Cli
impl FromArgMatches for Cli
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 Parser for Cli
impl Parser for Cli
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 Freeze for Cli
impl RefUnwindSafe for Cli
impl Send for Cli
impl Sync for Cli
impl Unpin for Cli
impl UnsafeUnpin for Cli
impl UnwindSafe for Cli
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