1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use anyhow::Error;
use argh::FromArgs;

mod backlight;
mod panel;
mod utils;

/// Top-level command line arguments.
#[derive(FromArgs, Debug, PartialEq)]
struct TopLevelArgs {
    #[argh(subcommand)]
    command: TweakCommand,
}

#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand)]
enum TweakCommand {
    Backlight(backlight::BacklightCmd),
    Panel(panel::PanelCmd),
}

#[fuchsia::main(logging = true, logging_tags = ["display-tweak"])]
async fn main() -> Result<(), Error> {
    let args: TopLevelArgs = argh::from_env();

    let command_result = match args.command {
        TweakCommand::Backlight(backlight_cmd) => backlight_cmd.exec().await,
        TweakCommand::Panel(panel_cmd) => panel_cmd.exec().await,
    };

    command_result
}