From 6cf59426a6e33ebaf5a769f88f5dda51a7e4cc1f Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:44:38 -0400 Subject: [PATCH] [src/lib/**.rs] Make `pub`lic useful symbols for use `cargo-make` as library --- src/lib/cli.rs | 2 +- src/lib/cli_commands/list_steps.rs | 4 ++-- src/lib/cli_commands/mod.rs | 4 ++-- src/lib/cli_commands/print_steps.rs | 2 +- src/lib/cli_parser.rs | 6 +++--- src/lib/config.rs | 8 ++++---- src/lib/mod.rs | 8 ++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lib/cli.rs b/src/lib/cli.rs index 9032bc82c..7760b9743 100644 --- a/src/lib/cli.rs +++ b/src/lib/cli.rs @@ -31,7 +31,7 @@ pub(crate) static DEFAULT_LOG_LEVEL: &str = "info"; pub(crate) static DEFAULT_TASK_NAME: &str = "default"; pub(crate) static DEFAULT_OUTPUT_FORMAT: &str = "default"; -fn run(cli_args: CliArgs, global_config: &GlobalConfig) { +pub fn run(cli_args: CliArgs, global_config: &GlobalConfig) { let start_time = SystemTime::now(); recursion_level::increment(); diff --git a/src/lib/cli_commands/list_steps.rs b/src/lib/cli_commands/list_steps.rs index daf139082..a49f7c155 100644 --- a/src/lib/cli_commands/list_steps.rs +++ b/src/lib/cli_commands/list_steps.rs @@ -13,7 +13,7 @@ use crate::io; use crate::types::{Config, DeprecationInfo}; use std::collections::{BTreeMap, BTreeSet}; -pub(crate) fn run( +pub fn run( config: &Config, output_format: &str, output_file: &Option, @@ -186,7 +186,7 @@ pub(crate) fn create_list( } if !just_task_name { - buffer.push_str(&format!("\n")); + buffer.push('\n'); } } diff --git a/src/lib/cli_commands/mod.rs b/src/lib/cli_commands/mod.rs index 85208434b..a72e91ef4 100644 --- a/src/lib/cli_commands/mod.rs +++ b/src/lib/cli_commands/mod.rs @@ -4,5 +4,5 @@ //! pub(crate) mod diff_steps; -pub(crate) mod list_steps; -pub(crate) mod print_steps; +pub mod list_steps; +pub mod print_steps; diff --git a/src/lib/cli_commands/print_steps.rs b/src/lib/cli_commands/print_steps.rs index cdc5a2ff4..c4540af4d 100644 --- a/src/lib/cli_commands/print_steps.rs +++ b/src/lib/cli_commands/print_steps.rs @@ -61,7 +61,7 @@ fn print_default(execution_plan: &ExecutionPlan) { } /// Only prints the execution plan -pub(crate) fn print( +pub fn print( config: &Config, task: &str, output_format: &str, diff --git a/src/lib/cli_parser.rs b/src/lib/cli_parser.rs index 1c756f127..1ab7306dd 100644 --- a/src/lib/cli_parser.rs +++ b/src/lib/cli_parser.rs @@ -146,7 +146,7 @@ fn get_args( cli_args } -fn create_cli(global_config: &GlobalConfig) -> CliSpec { +pub fn create_cli(global_config: &GlobalConfig) -> CliSpec { let default_task_name = match global_config.default_task_name { Some(ref value) => value.as_str(), None => &DEFAULT_TASK_NAME, @@ -468,7 +468,7 @@ fn create_cli(global_config: &GlobalConfig) -> CliSpec { spec } -pub(crate) fn parse_args( +pub fn parse_args( global_config: &GlobalConfig, command_name: &str, sub_command: bool, @@ -505,7 +505,7 @@ pub(crate) fn parse_args( } } -pub(crate) fn parse( +pub fn parse( global_config: &GlobalConfig, command_name: &str, sub_command: bool, diff --git a/src/lib/config.rs b/src/lib/config.rs index 8e4498d6e..ea1a1957c 100644 --- a/src/lib/config.rs +++ b/src/lib/config.rs @@ -13,14 +13,14 @@ use fsio::file::read_text_file; use fsio::path::from_path::FromPath; use std::path::{Path, PathBuf}; -static CONFIG_FILE: &'static str = "config.toml"; +pub static CONFIG_FILE: &'static str = "config.toml"; -fn get_config_directory() -> Option { +pub fn get_config_directory() -> Option { let os_directory = dirs_next::config_dir(); storage::get_storage_directory(os_directory, CONFIG_FILE, true) } -fn load_from_path(directory: PathBuf) -> GlobalConfig { +pub fn load_from_path(directory: PathBuf) -> GlobalConfig { let file_path = Path::new(&directory).join(CONFIG_FILE); debug!("Loading config from: {:#?}", &file_path); @@ -47,7 +47,7 @@ fn load_from_path(directory: PathBuf) -> GlobalConfig { } /// Returns the configuration -pub(crate) fn load() -> GlobalConfig { +pub fn load() -> GlobalConfig { match get_config_directory() { Some(directory) => load_from_path(directory), None => GlobalConfig::new(), diff --git a/src/lib/mod.rs b/src/lib/mod.rs index a7706856b..917a0cba1 100755 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -50,12 +50,12 @@ mod test; pub mod types; mod cache; -mod cli; -mod cli_commands; -mod cli_parser; +pub mod cli; +pub mod cli_commands; +pub mod cli_parser; mod command; mod condition; -mod config; +pub mod config; mod descriptor; mod environment; mod execution_plan;