pages-server/src/cli.rs
2022-07-16 02:25:31 +02:00

81 lines
2.7 KiB
Rust

// This file is part of the "lamp" program.
// Copyright (C) 2022 crapStone
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use clap::{App, Arg};
pub fn build_cli() -> App<'static> {
App::new("lamp")
.version(env!("CARGO_PKG_VERSION"))
.author("crapStone <crapstone01@gmail.com>")
.about("Utility to interact with backlight")
.global_setting(clap::AppSettings::ArgRequiredElseHelp)
.arg(
Arg::with_name("set")
.short('s')
.long("set")
.value_name("VALUE")
.help("Sets brightness to given value")
.takes_value(true),
)
.arg(
Arg::with_name("inc")
.short('i')
.long("increase")
.value_name("PERCENT")
.help("Increases brightness")
.takes_value(true),
)
.arg(
Arg::with_name("dec")
.short('d')
.long("decrease")
.value_name("PERCENT")
.help("Decreases brightness")
.takes_value(true),
)
.arg(
Arg::with_name("get")
.short('g')
.long("get")
.help("Prints current brightness value"),
)
.arg(
Arg::with_name("zero")
.short('z')
.long("zero")
.help("Sets brightness to lowest value"),
)
.arg(
Arg::with_name("full")
.short('f')
.long("full")
.help("Sets brightness to highest value"),
)
.arg(
Arg::with_name("list")
.short('l')
.long("list")
.help("Lists all available brightness and led controllers")
.exclusive(true),
)
.arg(
Arg::with_name("ctrl_type")
.short('t')
.long("type")
.value_name("controller_type")
.takes_value(true)
.possible_values(&["raw", "lin", "log"])
.default_value("lin")
.help("choose controller type")
.long_help(
r#"You can choose between these controller types:
raw: uses the raw values found in the device files
lin: uses percentage values (0.0 - 1.0) with a linear curve
log: uses percentage values (0.0 - 1.0) with a logarithmic curve
the perceived brightness for the human eyes should be linear with this controller
"#,
),
)
}