Skip to content

Commit

Permalink
fix: add codes
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Oct 14, 2024
1 parent 55b9239 commit f376dcc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions build/ten_runtime/feature/install_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self):
self.build_type: str
self.config_file: str
self.log_level: int
self.assume_yes: bool


if __name__ == "__main__":
Expand Down Expand Up @@ -56,6 +57,7 @@ def __init__(self):
parser.add_argument(
"--log-level", type=int, required=True, help="specify log level"
)
parser.add_argument("--assume-yes", type=bool, default=False)

arg_info = ArgumentInfo()
args = parser.parse_args(namespace=arg_info)
Expand All @@ -74,6 +76,9 @@ def __init__(self):
if args.config_file is not None:
cmd += ["--config-file=" + args.config_file]

if args.assume_yes:
cmd += ["--yes"]

cmd += ["install"]

if args.build_type is not None:
Expand Down
10 changes: 10 additions & 0 deletions build/ten_runtime/feature/test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ template("ten_package_test_prepare_app") {
args += [ "release" ]
}

args += [
"--assume-yes",
"True",
]

args += [
"--config-file",
rebase_path("${root_out_dir}/tests/local_registry/config.json"),
Expand Down Expand Up @@ -649,6 +654,11 @@ template("ten_package_standalone_pkg") {
args += [ "release" ]
}

args += [
"--assume-yes",
"True",
]

args += [
"--config-file",
rebase_path("${root_out_dir}/tests/local_registry/config.json"),
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_manager/src/cmd/cmd_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ pub async fn execute_cmd(
&all_existing_local_pkgs,
);

if has_conflict {
if has_conflict && !tman_config.assume_yes {
// "y" for continuing to install, "n" for stopping.
let ans = Confirm::new(
"Warning!!! Some local packages will be overwritten, \
Expand Down
8 changes: 8 additions & 0 deletions core/src/ten_manager/src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ fn create_cmd() -> clap::ArgMatches {
.help("Enable verbose output")
.action(clap::ArgAction::SetTrue),
)
.arg(
Arg::new("ASSUME_YES")
.short('y')
.long("yes")
.help("Automatically answer 'yes' to all prompts")
.action(clap::ArgAction::SetTrue),
)
.subcommand(crate::cmd::cmd_install::create_sub_cmd(&args_cfg))
.subcommand(crate::cmd::cmd_uninstall::create_sub_cmd(&args_cfg))
.subcommand(crate::cmd::cmd_package::create_sub_cmd(&args_cfg))
Expand All @@ -107,6 +114,7 @@ pub fn parse_cmd(
tman_config.user_token = matches.get_one::<String>("USER_TOKEN").cloned();
tman_config.mi_mode = matches.get_flag("MI");
tman_config.verbose = matches.get_flag("VERBOSE");
tman_config.assume_yes = matches.get_flag("ASSUME_YES");

match matches.subcommand() {
Some(("install", sub_cmd_args)) => crate::cmd::CommandData::Install(
Expand Down
2 changes: 2 additions & 0 deletions core/src/ten_manager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct TmanConfig {

pub mi_mode: bool,
pub verbose: bool,
pub assume_yes: bool,
}

// Determine the config file path based on the platform.
Expand Down Expand Up @@ -94,5 +95,6 @@ pub fn read_config(config_file_path: &Option<String>) -> TmanConfig {
user_token: config_file_content.user_token,
mi_mode: false,
verbose: false,
assume_yes: false,
}
}
1 change: 1 addition & 0 deletions core/src/ten_manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn merge(cmd_line: TmanConfig, config_file: TmanConfig) -> TmanConfig {
user_token: cmd_line.user_token.or(config_file.user_token),
mi_mode: cmd_line.mi_mode,
verbose: cmd_line.verbose,
assume_yes: cmd_line.assume_yes,
}
}

Expand Down

0 comments on commit f376dcc

Please sign in to comment.