pub async fn generate_command(matches: &ArgMatches) -> Result<()> {
    let fs_content = std::fs::read(matches.value_of("file").unwrap())?;

    let fs_out = matches.value_of("output").unwrap();

    // Supercede and process singular include only
    if matches.is_present("include") {
        let res = alternator::consume("chumbucket", fs_content).await?;

        write_to_disk(fs_out, res)?;

        return Ok(());
    }

    let manifest: Manifest = toml::from_slice(&fs_content)?;
    let mut bundle: Option<Bundle> = None;
    let mut from_time: Option<i64> = None;

    if matches.is_present("bundle") {
        let bundle_str = std::fs::read(matches.value_of("bundle").unwrap())?;

        let parsed_bundle: Bundle = serde_json::from_slice(&bundle_str)?;

        if let Some(version) = &parsed_bundle.version {
            from_time = Some(version.time);
        }

        bundle = Some(parsed_bundle);
    }

    match manifest.source.r#type {
        SourceType::Git => {
            let mut walker = Walker::from_remote(
                &manifest
                    .source
                    .repository
                    .clone()
                    .ok_or(anyhow!("Missing source repository"))?,
                &manifest.meta.name,
                manifest
                    .source
                    .patterns
                    .clone()
                    .ok_or(anyhow!("Missing source patterns"))?,
            )?;

            let git = accessors::Git::from_walker(from_time, &mut walker)?;

            let it_ret = iterate_chronicles(git, manifest, bundle).await?;

            // If there are differences, write to file
            // JSON object keys are not guaranteed to be in ordered each time
            // This check exists to avoid changing of E-tag on CDN proxy
            if it_ret.1 > 0 {
                write_to_disk(fs_out, it_ret.0)?;
            }
        }
        // TODO: Implement direct
        _ => (),
    };

    Ok(())
}
/// Generate Subcommand
/// Takes independent manifest or include file and convert to Bundle or AlternatorSrand
Generate Subcommand
Takes independent manifest or include file and convert to Bundle or AlternatorSrand
Generate Subcommand Takes independent manifest or include file and convert to Bundle or AlternatorSrand
pub async fn generate_command(matches: &ArgMatches) -> Result<()> {
    let fs_content = std::fs::read(matches.value_of("file").unwrap())?;
    let fs_out = matches.value_of("output").unwrap();
    // Supercede and process singular include only
    if matches.is_present("include") {
        let res = alternator::consume("chumbucket", fs_content).await?;
        write_to_disk(fs_out, res)?;
        return Ok(());
    }
    let manifest: Manifest = toml::from_slice(&fs_content)?;
    let mut bundle: Option<Bundle> = None;
    let mut from_time: Option<i64> = None;
    if matches.is_present("bundle") {
        let bundle_str = std::fs::read(matches.value_of("bundle").unwrap())?;
        let parsed_bundle: Bundle = serde_json::from_slice(&bundle_str)?;
        if let Some(version) = &parsed_bundle.version {
            from_time = Some(version.time);
        }
        bundle = Some(parsed_bundle);
    }
    match manifest.source.r#type {
        SourceType::Git => {
            let mut walker = Walker::from_remote(
                &manifest
                    .source
                    .repository
                    .clone()
                    .ok_or(anyhow!("Missing source repository"))?,
                &manifest.meta.name,
                manifest
                    .source
                    .patterns
                    .clone()
                    .ok_or(anyhow!("Missing source patterns"))?,
            )?;
            let git = accessors::Git::from_walker(from_time, &mut walker)?;
            let it_ret = iterate_chronicles(git, manifest, bundle).await?;
            // If there are differences, write to file
            // JSON object keys are not guaranteed to be in ordered each time
            // This check exists to avoid changing of E-tag on CDN proxy
            if it_ret.1 > 0 {
                write_to_disk(fs_out, it_ret.0)?;
            }
        }
        // TODO: Implement direct
        _ => (),
    };
    Ok(())
}
pub async fn generate_command ( matches : & ArgMatches ) -> Result < ( ) > { let fs_content = std :: fs :: read ( matches . value_of ( " " ) . unwrap ( ) ) ? ; let fs_out = matches . value_of ( " " ) . unwrap ( ) ; // Supercede and process singular include only if matches . is_present ( " " ) { let res = alternator :: consume ( " " , fs_content ) . await ? ; write_to_disk ( fs_out , res ) ? ; return Ok ( ( ) ) ; } let manifest : Manifest = toml :: from_slice ( & fs_content ) ? ; let mut bundle : Option < Bundle > = None ; let mut from_time : Option < i64 > = None ; if matches . is_present ( " " ) { let bundle_str = std :: fs :: read ( matches . value_of ( " " ) . unwrap ( ) ) ? ; let parsed_bundle : Bundle = serde_json :: from_slice ( & bundle_str ) ? ; if let Some ( version ) = & parsed_bundle . version { from_time = Some ( version . time ) ; } bundle = Some ( parsed_bundle ) ; } match manifest . source . r#type { SourceType :: Git => { let mut walker = Walker :: from_remote ( & manifest . source . repository . clone ( ) . ok_or ( anyhow ! ( " " ) ) ? , & manifest . meta . name , manifest . source . patterns . clone ( ) . ok_or ( anyhow ! ( " " ) ) ? , ) ? ; let git = accessors :: Git :: from_walker ( from_time , & mut walker ) ? ; let it_ret = iterate_chronicles ( git , manifest , bundle ) . await ? ; // If there are differences, write to file // JSON object keys are not guaranteed to be in ordered each time // This check exists to avoid changing of E-tag on CDN proxy if it_ret . 1 > 0 { write_to_disk ( fs_out , it_ret . 0 ) ? ; } } // TODO: Implement direct _ => ( ) , } ; Ok ( ( ) ) }
Generate Subcommand
Takes independent manifest or include file and convert to Bundle or AlternatorSrand
Generate Subcommand Takes independent manifest or include file and convert to Bundle or AlternatorSrand
matches
&ArgMatches