Skip to content

Commit

Permalink
cli: rename ConfigArgs to ConfigLevelArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed May 12, 2024
1 parent 9559359 commit 717b422
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cli/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::ui::Ui;

#[derive(clap::Args, Clone, Debug)]
#[command(group = clap::ArgGroup::new("config_level").multiple(false).required(true))]
pub(crate) struct ConfigArgs {
pub(crate) struct ConfigLevelArgs {
/// Target the user-level config
#[arg(long, group = "config_level")]
user: bool,
Expand All @@ -41,7 +41,7 @@ pub(crate) struct ConfigArgs {
repo: bool,
}

impl ConfigArgs {
impl ConfigLevelArgs {
fn get_source_kind(&self) -> ConfigSource {
if self.user {
ConfigSource::User
Expand Down Expand Up @@ -145,7 +145,7 @@ pub(crate) struct ConfigSetArgs {
#[arg(required = true)]
value: String,
#[command(flatten)]
config_args: ConfigArgs,
level: ConfigLevelArgs,
}

/// Start an editor on a jj config file.
Expand All @@ -155,7 +155,7 @@ pub(crate) struct ConfigSetArgs {
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct ConfigEditArgs {
#[command(flatten)]
pub config_args: ConfigArgs,
pub level: ConfigLevelArgs,
}

/// Print the path to the config file
Expand All @@ -166,7 +166,7 @@ pub(crate) struct ConfigEditArgs {
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct ConfigPathArgs {
#[command(flatten)]
pub config_args: ConfigArgs,
pub level: ConfigLevelArgs,
}

#[instrument(skip_all)]
Expand Down Expand Up @@ -309,7 +309,7 @@ pub(crate) fn cmd_config_set(
command: &CommandHelper,
args: &ConfigSetArgs,
) -> Result<(), CommandError> {
let config_path = get_new_config_file_path(&args.config_args.get_source_kind(), command)?;
let config_path = get_new_config_file_path(&args.level.get_source_kind(), command)?;
if config_path.is_dir() {
return Err(user_error(format!(
"Can't set config in path {path} (dirs not supported)",
Expand All @@ -325,7 +325,7 @@ pub(crate) fn cmd_config_edit(
command: &CommandHelper,
args: &ConfigEditArgs,
) -> Result<(), CommandError> {
let config_path = get_new_config_file_path(&args.config_args.get_source_kind(), command)?;
let config_path = get_new_config_file_path(&args.level.get_source_kind(), command)?;
run_ui_editor(command.settings(), &config_path)
}

Expand All @@ -335,7 +335,7 @@ pub(crate) fn cmd_config_path(
command: &CommandHelper,
args: &ConfigPathArgs,
) -> Result<(), CommandError> {
let config_path = get_new_config_file_path(&args.config_args.get_source_kind(), command)?;
let config_path = get_new_config_file_path(&args.level.get_source_kind(), command)?;
writeln!(
ui.stdout(),
"{}",
Expand Down

0 comments on commit 717b422

Please sign in to comment.