pages-server/src/cli.rs

82 lines
2.7 KiB
Rust
Raw Normal View History

2022-07-15 23:55:31 +02:00
// 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/>.
2022-07-16 02:22:57 +02:00
use clap::{App, Arg};
2020-07-22 18:47:26 +02:00
2022-07-15 23:34:09 +02:00
pub fn build_cli() -> App<'static> {
2021-10-05 14:12:22 +02:00
App::new("lamp")
.version(env!("CARGO_PKG_VERSION"))
.author("crapStone <crapstone01@gmail.com>")
2020-07-22 18:47:26 +02:00
.about("Utility to interact with backlight")
.global_setting(clap::AppSettings::ArgRequiredElseHelp)
2020-07-22 18:47:26 +02:00
.arg(
Arg::with_name("set")
2022-07-15 23:34:09 +02:00
.short('s')
2020-07-22 18:47:26 +02:00
.long("set")
.value_name("VALUE")
.help("Sets brightness to given value")
.takes_value(true),
)
.arg(
Arg::with_name("inc")
2022-07-15 23:34:09 +02:00
.short('i')
2020-07-22 18:47:26 +02:00
.long("increase")
.value_name("PERCENT")
.help("Increases brightness")
.takes_value(true),
)
.arg(
Arg::with_name("dec")
2022-07-15 23:34:09 +02:00
.short('d')
2020-07-22 18:47:26 +02:00
.long("decrease")
.value_name("PERCENT")
.help("Decreases brightness")
.takes_value(true),
)
.arg(
Arg::with_name("get")
2022-07-15 23:34:09 +02:00
.short('g')
2020-07-22 18:47:26 +02:00
.long("get")
.help("Prints current brightness value"),
)
.arg(
2022-07-16 01:17:20 +02:00
Arg::with_name("zero")
2022-07-15 23:34:09 +02:00
.short('z')
2020-07-22 18:47:26 +02:00
.long("zero")
.help("Sets brightness to lowest value"),
)
.arg(
2022-07-16 01:17:20 +02:00
Arg::with_name("full")
2022-07-15 23:34:09 +02:00
.short('f')
2020-07-22 18:47:26 +02:00
.long("full")
.help("Sets brightness to highest value"),
)
.arg(
Arg::with_name("list")
2022-07-15 23:34:09 +02:00
.short('l')
2020-07-22 18:47:26 +02:00
.long("list")
.help("Lists all available brightness and led controllers")
2022-07-16 02:22:57 +02:00
.exclusive(true)
2020-07-22 18:47:26 +02:00
)
.arg(
Arg::with_name("ctrl_type")
2022-07-15 23:34:09 +02:00
.short('t')
2020-07-22 18:47:26 +02:00
.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
2022-07-16 01:01:48 +02:00
lin: uses percentage values (0.0 - 1.0) with a linear curve
log: uses percentage values (0.0 - 1.0) with a logarithmic curve
2020-07-22 18:47:26 +02:00
the perceived brightness for the human eyes should be linear with this controller
"#,
),
)
}