Skip to content

Commit eceac4a

Browse files
committed
feat: re-add ask config onboard ui
1 parent 5589cc9 commit eceac4a

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

cli/src/actions/workspace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use dialoguer::{theme::ColorfulTheme, Confirm, FuzzySelect, Input};
88
use log::info;
99

1010
use crate::{
11-
config::{ask_for_init_config, patch_instance_config, patch_workspace_config},
11+
config::{ask_for_config, patch_instance_config, patch_workspace_config},
1212
download::{download_file, pick_latest_rootfs, CIEL_MAINLINE_ARCHS, CIEL_RETRO_ARCHS},
1313
logger::style_bool,
1414
make_progress_bar,
@@ -75,7 +75,7 @@ pub fn new_workspace(args: &ArgMatches) -> Result<()> {
7575
if arch.is_none() {
7676
arch = Some(ask_for_target_arch()?.to_owned())
7777
}
78-
ask_for_init_config(&mut config)?;
78+
ask_for_config(&mut config)?;
7979
} else {
8080
info!("Running in unattended mode, using default configuration ...");
8181
}

cli/src/config.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ use log::info;
88

99
use crate::utils::get_host_arch_name;
1010

11+
const WORKSPACE_ARGS: &[&str] = &[
12+
"maintainer",
13+
"dnssec",
14+
"repo",
15+
"local-repo",
16+
"source-cache",
17+
"nspawn-opt",
18+
"branch-exclusive-output",
19+
"volatile-mount",
20+
"use-apt",
21+
];
22+
1123
#[inline]
1224
fn config_list<V>(args: &ArgMatches, id: &str, list: &mut Vec<V>)
1325
where
@@ -81,6 +93,19 @@ pub fn config_instance(instance: &str, args: &ArgMatches) -> Result<()> {
8193

8294
/// Applies workspace configuration patches from [ArgMatches].
8395
pub fn patch_workspace_config(args: &ArgMatches, config: &mut WorkspaceConfig) -> Result<()> {
96+
let mut has_args = false;
97+
for i in WORKSPACE_ARGS {
98+
if args.get_raw(i).is_some() {
99+
has_args = true;
100+
break;
101+
}
102+
}
103+
104+
if !has_args {
105+
ask_for_config(config)?;
106+
return Ok(());
107+
}
108+
84109
if let Some(maintainer) = args.get_one::<String>("maintainer") {
85110
if maintainer != &config.maintainer {
86111
WorkspaceConfig::validate_maintainer(maintainer)?;
@@ -138,7 +163,7 @@ pub fn patch_instance_config(args: &ArgMatches, config: &mut InstanceConfig) ->
138163
}
139164

140165
/// Shows a series of prompts to let the user select the configurations
141-
pub fn ask_for_init_config(config: &mut WorkspaceConfig) -> Result<()> {
166+
pub fn ask_for_config(config: &mut WorkspaceConfig) -> Result<()> {
142167
let theme = ColorfulTheme::default();
143168
config.maintainer = Input::<String>::with_theme(&theme)
144169
.with_prompt("Maintainer")

0 commit comments

Comments
 (0)