From 3cc09cd87004fa7a6a158f05ee46ea8b61534220 Mon Sep 17 00:00:00 2001 From: Syed Ahkam Date: Sat, 8 Jul 2023 05:38:17 +0530 Subject: [PATCH] feat: configure sdk versions while creating project It's now possible to supply min-sdk-version, compile-sdk-version and target-sdk-version flags while invoking the `create` command. --- src/commands/create.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/commands/create.rs b/src/commands/create.rs index 1e7036f..f49deee 100644 --- a/src/commands/create.rs +++ b/src/commands/create.rs @@ -11,6 +11,10 @@ use crate::utils::prompt_for_input; const DEFAULT_TEMPLATE_REPO: &str = "https://github.com/SyedAhkam/android-cli-template"; const TEMPLATE_REV: &str = "master"; +const DEFAULT_COMPILE_SDK_VERSION: &str = "33"; +const DEFAULT_TARGET_SDK_VERSION: &str = "33"; +const DEFAULT_MIN_SDK_VERSION: &str = "24"; + #[derive(Parser, Debug)] pub struct Create { #[clap(value_parser)] @@ -31,6 +35,18 @@ pub struct Create { /// Package identifier [example: com.example.demo] #[clap(long)] package_id: Option, + + /// SDK version the app is compiled against + #[clap(long, default_value = DEFAULT_COMPILE_SDK_VERSION)] + compile_sdk_version: u32, + + /// SDK version the app is targeting + #[clap(long, default_value = DEFAULT_TARGET_SDK_VERSION)] + target_sdk_version: u32, + + /// Minimum SDK version that the app supports + #[clap(long, default_value = DEFAULT_MIN_SDK_VERSION)] + min_sdk_version: u32 } fn get_vars(args: &Create) -> BTreeMap { @@ -59,11 +75,10 @@ fn get_vars(args: &Create) -> BTreeMap { map.insert("package_id_org".into(), org); map.insert("package_id_name".into(), name); - // Version numbers, hardcoded for now - // TODO: make these configurable - map.insert("compile_sdk_version".into(), "33".into()); - map.insert("min_sdk_version".into(), "24".to_string()); - map.insert("target_sdk_version".into(), "33".to_string()); + // Version numbers + map.insert("compile_sdk_version".into(), args.compile_sdk_version.to_string()); + map.insert("target_sdk_version".into(), args.target_sdk_version.to_string()); + map.insert("min_sdk_version".into(), args.min_sdk_version.to_string()); map }