multiversx_sc_meta/cmd/template/
template_list.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::cli::TemplateListArgs;

use super::{contract_creator::get_repo_version, template_source::template_sources, RepoSource};

pub async fn print_template_names(args: &TemplateListArgs) {
    let version = get_repo_version(&args.tag);
    let repo_temp_download = RepoSource::download_from_github(version, std::env::temp_dir()).await;
    let template_names = template_names_from_repo(&repo_temp_download);
    for template_name in template_names {
        println!("{template_name}");
    }
}

pub fn template_names_from_repo(repo_temp_download: &RepoSource) -> Vec<String> {
    let sources = template_sources(repo_temp_download);
    sources
        .iter()
        .map(|source| source.metadata.name.clone())
        .collect()
}