1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::modules::services::databases;
use crate::modules::services::utils::{get_config_using_env, read_config_file};
use crate::modules::types::cli::Cli;
use crate::modules::types::config::Config;

/// Print all tables
pub fn run_tables(args: Cli) -> () {
    let config: Config;

    if args.use_env == true {
        config = get_config_using_env();
    } else {
        config = read_config_file();
    }

    let tables: Vec<String> = get_tables(config);

    println!("Tables / Collections:");
    for table in tables {
        println!("{}", table);
    }
}

/// Return vec with table names
fn get_tables(config: Config) -> Vec<String> {
    let raw_tables = databases::list(config.clone());
    if raw_tables.is_some() {
        let tables = raw_tables.unwrap();
        return tables;
    }

    return vec![];
}