Commit 367c712e authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

feat: Add commit option to export command

parent 5bdc0b29
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -131,6 +131,9 @@ pub enum Commands {
        /// Path of input files to be exported
        #[arg(short, long, value_name = "PATH", value_hint = ValueHint::DirPath)]
        path: Option<PathBuf>,
        /// Export files that were changed in a given Git commit
        #[arg(short, long, value_name = "COMMIT")]
        commit: Option<String>,
        /// Export target type
        #[arg(default_value_t, short, long, value_name = "TARGET")]
        target: Target,
+17 −12
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ use crate::template::get_html;
use acorn_lib::schema::ResearchActivity;
use acorn_lib::util::cli::{Options, Size, Target};
use acorn_lib::util::{cli, path_to_string};
use acorn_lib::util::{get_all_files, tokio_runtime, Label};
use acorn_lib::util::{get_all_files, get_files_from_git, tokio_runtime, Label};
use color_eyre::eyre::{Report, Result};
use indicatif::{ProgressBar, ProgressStyle};
use playwright::api::Page;
@@ -57,7 +57,20 @@ pub async fn create_pdf(page: &Page, options: cli::Options) {
    };
    let _remove = remove_file(index);
}
pub fn run(output: &Option<PathBuf>, path: &Option<PathBuf>, size: &Size, target: &Target) -> Result<(), Report> {
pub fn run(output: &Option<PathBuf>, path: &Option<PathBuf>, commit: &Option<String>, size: &Size, target: &Target) -> Result<(), Report> {
    fn get_paths_from_options(path: &Option<PathBuf>, commit: &Option<String>) -> Vec<PathBuf> {
        let extension = Some("json");
        match commit {
            | Some(hash) => get_files_from_git(hash, extension),
            | None => {
                let value = match path {
                    | Some(x) => x.clone(),
                    | None => PathBuf::from("."),
                };
                get_all_files(value, extension)
            }
        }
    }
    match target {
        | Target::FactSheet => {
            tokio_runtime().block_on(async {
@@ -67,11 +80,7 @@ pub fn run(output: &Option<PathBuf>, path: &Option<PathBuf>, size: &Size, target
                let browser = chromium.launcher().headless(true).launch().await.unwrap();
                let context = browser.context_builder().build().await.unwrap();
                let page = context.new_page().await.unwrap();
                let input_path = match path.clone() {
                    | Some(value) => value,
                    | None => unimplemented!(),
                };
                let paths = get_all_files(input_path.clone(), None);
                let paths = get_paths_from_options(path, commit);
                let progress = ProgressBar::new(paths.len() as u64);
                progress.set_style(ProgressStyle::with_template(Label::PROGRESS_BAR_TEMPLATE).unwrap());
                for path in paths {
@@ -99,11 +108,7 @@ pub fn run(output: &Option<PathBuf>, path: &Option<PathBuf>, size: &Size, target
                let browser = chromium.launcher().headless(true).launch().await.unwrap();
                let context = browser.context_builder().build().await.unwrap();
                let page = context.new_page().await.unwrap();
                let input_path = match path.clone() {
                    | Some(value) => value,
                    | None => unimplemented!(),
                };
                let paths = get_all_files(input_path.clone(), None);
                let paths = get_paths_from_options(path, commit);
                let progress = ProgressBar::new(paths.len() as u64);
                progress.set_style(ProgressStyle::with_template(Label::PROGRESS_BAR_TEMPLATE).unwrap());
                for path in paths {
+7 −2
Original line number Diff line number Diff line
@@ -74,8 +74,13 @@ fn main() -> Void {
        | Some(Commands::Doctor { fix, interactive, check, .. }) => commands::doctor::run(fix, interactive, check),
        | Some(Commands::Download { buckets, output, .. }) => commands::download::run(buckets, output),
        | Some(Commands::Export {
            output, path, size, target, ..
        }) => commands::export::run(output, path, size, target),
            output,
            path,
            commit,
            size,
            target,
            ..
        }) => commands::export::run(output, path, commit, size, target),
        | Some(Commands::Format {
            path,
            commit,
+49 −45
Original line number Diff line number Diff line
@@ -35,18 +35,18 @@ FN:6,should_run
FN:10,run
FNF:2
FNDA:1,should_run
FNDA:4,run
FNDA:5,run
DA:6,1
DA:7,7
DA:10,4
DA:11,2
DA:14,4
DA:17,2
DA:10,5
DA:11,1
DA:14,5
DA:17,5
DA:18,1
DA:20,3
DA:20,5
DA:21,2
DA:23,2
DA:24,1
DA:24,2
DA:26,2
DA:27,1
DA:30,2
@@ -79,9 +79,11 @@ TN:
SF:/root/dev/acorn/acorn-cli/src/commands/export/mod.rs
FN:14,create_pdf
FN:60,run
FNF:2
FN:61,run::get_paths_from_options
FNF:3
FNDA:0,create_pdf
FNDA:0,run
FNDA:0,run::get_paths_from_options
DA:14,0
DA:15,0
DA:16,0
@@ -109,18 +111,14 @@ DA:49,0
DA:58,0
DA:60,0
DA:61,0
DA:62,0
DA:63,0
DA:64,0
DA:65,0
DA:66,0
DA:67,0
DA:68,0
DA:69,0
DA:70,0
DA:71,0
DA:72,0
DA:74,0
DA:75,0
DA:76,0
DA:77,0
DA:78,0
@@ -129,22 +127,23 @@ DA:80,0
DA:81,0
DA:82,0
DA:83,0
DA:84,0
DA:85,0
DA:86,0
DA:87,0
DA:88,0
DA:89,0
DA:90,0
DA:91,0
DA:93,0
DA:92,0
DA:94,0
DA:95,0
DA:96,0
DA:97,0
DA:98,0
DA:99,0
DA:100,0
DA:101,0
DA:102,0
DA:103,0
DA:104,0
DA:105,0
DA:106,0
DA:107,0
DA:108,0
@@ -155,12 +154,17 @@ DA:112,0
DA:113,0
DA:114,0
DA:115,0
DA:116,0
DA:117,0
DA:118,0
DA:119,0
DA:120,0
DA:121,0
DA:122,0
DA:123,0
LF:78
DA:125,0
DA:126,0
DA:128,0
LF:80
LH:0
end_of_record
TN:
@@ -225,8 +229,8 @@ DA:67,0
DA:74,0
DA:75,0
DA:76,0
DA:79,0
DA:86,0
DA:84,0
DA:91,0
LF:19
LH:0
end_of_record
@@ -591,7 +595,7 @@ FNDA:2,<impl TableFormatPrint for MemoryInformation>::print
FNDA:1,<impl TableFormatPrint for NetworkInformation>::init
FNDA:1,<impl TableFormatPrint for NetworkInformation>::print
FNDA:1,<impl TableFormatPrint for SystemInformation>::init
FNDA:1,<impl TableFormatPrint for SystemInformation>::print
FNDA:2,<impl TableFormatPrint for SystemInformation>::print
FNDA:0,print_system_information
FNDA:1,parse_network_addresses
DA:46,1
@@ -650,28 +654,28 @@ DA:127,1
DA:128,1
DA:129,1
DA:130,2
DA:133,1
DA:134,1
DA:135,1
DA:136,1
DA:137,1
DA:138,1
DA:139,1
DA:140,1
DA:142,1
DA:143,2
DA:144,2
DA:145,2
DA:146,2
DA:147,2
DA:148,2
DA:150,1
DA:151,4
DA:154,1
DA:155,1
DA:156,2
DA:157,1
DA:159,1
DA:133,2
DA:134,2
DA:135,2
DA:136,2
DA:137,2
DA:138,2
DA:139,2
DA:140,2
DA:142,2
DA:143,4
DA:144,4
DA:145,4
DA:146,4
DA:147,4
DA:148,4
DA:150,2
DA:151,8
DA:154,2
DA:155,2
DA:156,4
DA:157,2
DA:159,2
DA:162,0
DA:163,0
DA:164,0