M build.rs +0 -3
@@ 1,6 1,3 @@
-#[macro_use]
-extern crate clap;
-
use std::env;
use std::fs;
use std::path::PathBuf;
M src/bin/brightctl.rs +5 -12
@@ 1,14 1,7 @@
-extern crate dbus;
-#[macro_use]
-extern crate failure;
-#[macro_use]
-extern crate clap;
-
-extern crate bright;
-
use std::collections::HashMap;
-use bright::*;
+use clap::value_t;
+use failure::format_err;
// Application configuration
#[derive(Debug)]
@@ 46,7 39,7 @@ enum Action {
impl AppConfig {
fn new(argv: &[String]) -> Result<AppConfig, failure::Error> {
- let matches = cli::brightctl_app().get_matches_from(argv);
+ let matches = bright::cli::brightctl_app().get_matches_from(argv);
let action: Action = match matches.subcommand() {
("get", _) => Action::Get,
("watch", _) => Action::Watch,
@@ 148,7 141,7 @@ fn get_brightness_dbus(cfg: &AppConfig)
}
fn get_brightness_direct(cfg: &AppConfig) -> Result<(), failure::Error> {
- let devices = create_devices(cfg.devices.clone())?;
+ let devices = bright::create_devices(cfg.devices.clone())?;
for dev in devices.iter() {
println!("{}/{}", dev.name(), dev.get()?);
}
@@ 200,7 193,7 @@ fn set_brightness_dbus(cfg: &AppConfig)
}
fn set_brightness_direct(cfg: &AppConfig) -> Result<(), failure::Error> {
- let devices = create_devices(cfg.devices.clone())?;
+ let devices = bright::create_devices(cfg.devices.clone())?;
for dev in devices.iter() {
match cfg.action {
Action::Set(n) => {
M src/bin/brightd.rs +1 -10
@@ 1,19 1,10 @@
-extern crate ctrlc;
-extern crate dbus;
-extern crate failure;
-extern crate simplelog;
-extern crate systemd;
-#[macro_use]
-extern crate log;
-
-extern crate bright;
-
use std::io::prelude::*;
use std::os::unix::net::UnixStream;
use std::rc::Rc;
use std::sync::mpsc;
use failure::ResultExt;
+use log::{debug, error, info};
fn main() {
let argv: Vec<String> = std::env::args().collect();
M src/cli.rs +1 -1
@@ 1,4 1,4 @@
-use clap::{App, AppSettings, Arg, SubCommand};
+use clap::{crate_version, App, AppSettings, Arg, SubCommand};
pub fn brightctl_app() -> App<'static, 'static> {
App::new("brightctl")
M src/dbus.rs +3 -5
@@ 28,17 28,15 @@
// /be/devork/dbus/bright/devices/<name>, however you should only
// ever acquire these object paths from the manager.
-extern crate dbus;
-extern crate failure;
-extern crate log;
-
use std;
use std::collections::HashMap;
use std::rc::Rc;
use std::sync::Arc;
-use dbus::stdintf::org_freedesktop_dbus::Properties;
+use dbus::{self, stdintf::org_freedesktop_dbus::Properties};
use failure::ResultExt;
+use failure_derive::Fail;
+use log::{debug, error, info};
// The public DBus names we use.
pub static BUSNAME: &'static str = "be.devork.dbus.bright";
M src/lib.rs +3 -12
@@ 1,18 1,11 @@
-#[macro_use]
-extern crate failure;
-#[macro_use]
-extern crate clap;
-#[macro_use]
-extern crate log;
+use std::fmt;
+use std::fs;
+use std::io::prelude::*;
pub mod cli;
pub mod dbus;
pub mod pond;
-use std::fmt;
-use std::fs;
-use std::io::prelude::*;
-
pub fn create_devices(only: Vec<String>) -> Result<Vec<BacklightDevice>, failure::Error> {
let base = std::path::Path::new("/sys/class/backlight/");
let entries = base.read_dir()?;
@@ 145,7 138,6 @@ fn read_uint(path: &std::path::Path) ->
#[cfg(test)]
mod tests {
- extern crate tempfile;
use super::*;
use std::fs;
@@ 257,5 249,4 @@ mod tests {
dev.decr(5).unwrap();
assert_eq!(dev.get().unwrap(), 0);
}
-
}