<commit_before>use command_prelude::*;

use cargo::print_json;

pub fn cli() -> App {
    subcommand("locate-project")
        .about("Checkout a copy of a Git repository")
        .arg_manifest_path()
}

#[derive(Serialize)]
pub struct ProjectLocation {
    root: String,
}

pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
    let root = args.root_manifest(config)?;

    let root = root.to_str()
        .ok_or_else(|| {
            format_err!(
                "your project path contains characters \
                 not representable in Unicode"
            )
        })
        .map_err(|e| CliError::new(e, 1))?
        .to_string();

    let location = ProjectLocation { root };

    print_json(&location);
    Ok(())
}
<commit_msg>Auto merge of #5290 - ehuss:lp-help, r=matklad<commit_after>use command_prelude::*;

use cargo::print_json;

pub fn cli() -> App {
    subcommand("locate-project")
        .about("Print a JSON representation of a Cargo.toml file's location")
        .arg_manifest_path()
}

#[derive(Serialize)]
pub struct ProjectLocation {
    root: String,
}

pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
    let root = args.root_manifest(config)?;

    let root = root.to_str()
        .ok_or_else(|| {
            format_err!(
                "your project path contains characters \
                 not representable in Unicode"
            )
        })
        .map_err(|e| CliError::new(e, 1))?
        .to_string();

    let location = ProjectLocation { root };

    print_json(&location);
    Ok(())
}

{'fraction_non_alphanumeric': 0.1306277742549144, 'fraction_numerical': 0.003804692454026633, 'mean_word_length': 2.4008620689655173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7538504', 'n_tokens_mistral': 509, 'n_tokens_neox': 490, 'n_words': 123}