aboutsummaryrefslogtreecommitdiff
path: root/mling/src/proj_mgr
diff options
context:
space:
mode:
Diffstat (limited to 'mling/src/proj_mgr')
-rw-r--r--mling/src/proj_mgr/generator.rs27
-rw-r--r--mling/src/proj_mgr/show_binaries.rs21
-rw-r--r--mling/src/proj_mgr/show_directories.rs21
3 files changed, 45 insertions, 24 deletions
diff --git a/mling/src/proj_mgr/generator.rs b/mling/src/proj_mgr/generator.rs
index 48a1753..e560ae0 100644
--- a/mling/src/proj_mgr/generator.rs
+++ b/mling/src/proj_mgr/generator.rs
@@ -1,11 +1,12 @@
use std::path::{self, PathBuf};
use mingling::{
- Groupped,
- macros::{chain, pack, r_println, renderer, route},
+ macros::{chain, pack, renderer, route},
+ Groupped, RenderResult,
};
+use std::io::Write as _;
-use crate::{Next, proj_mgr::EntryGenerateProject, res::ResCurrentDir};
+use crate::{proj_mgr::EntryGenerateProject, res::ResCurrentDir, Next};
pack!(StateGenerateProjectReady = PathBuf);
pack!(ResultGenerateProjectChecklistCreated = PathBuf);
@@ -35,12 +36,22 @@ pub fn handle_state_gen_proj_ready(prev: StateGenerateProjectReady) -> Next {
}
#[renderer]
-pub fn render_gen_proj_checklist_created(result: ResultGenerateProjectChecklistCreated) {
- r_println!(
+pub fn render_gen_proj_checklist_created(
+ result: ResultGenerateProjectChecklistCreated,
+) -> RenderResult {
+ let mut res = RenderResult::default();
+ writeln!(
+ res,
"Successfully create {} at \"{}\"",
CHECK_LIST_NAME,
result.to_string_lossy()
- );
- r_println!("");
- r_println!("Please fill in {CHECK_LIST_NAME} and run `mling gen` again to continue generating");
+ )
+ .ok();
+ writeln!(res).ok();
+ writeln!(
+ res,
+ "Please fill in {CHECK_LIST_NAME} and run `mling gen` again to continue generating"
+ )
+ .ok();
+ res
}
diff --git a/mling/src/proj_mgr/show_binaries.rs b/mling/src/proj_mgr/show_binaries.rs
index d6872cf..fd2f406 100644
--- a/mling/src/proj_mgr/show_binaries.rs
+++ b/mling/src/proj_mgr/show_binaries.rs
@@ -2,18 +2,19 @@ use std::path::PathBuf;
use colored::Colorize;
use mingling::{
- Groupped,
- macros::{chain, pack, r_print, r_println, renderer},
+ macros::{chain, pack, renderer},
+ Groupped, RenderResult,
};
use serde::Serialize;
+use std::io::Write as _;
use crate::{
- Next,
proj_mgr::{
+ metadata::{read_metadata, CargoLockFile},
EntryShowBinaries,
- metadata::{CargoLockFile, read_metadata},
},
res::ResManifestPath,
+ Next,
};
#[derive(Serialize, Groupped)]
@@ -58,16 +59,20 @@ pub fn handle_show_binaries(_args: EntryShowBinaries, manifest_path: &ResManifes
}
#[renderer]
-pub fn render_binaries(binaries: ResultBinaries) -> String {
- r_println!("{}", "Binaries:".bright_cyan().bold());
+pub fn render_binaries(binaries: ResultBinaries) -> RenderResult {
+ let mut result = RenderResult::default();
+ writeln!(result, "{}", "Binaries:".bright_cyan().bold()).ok();
if let Some(max_name_len) = binaries.binaries.iter().map(|b| b.name.len()).max() {
for binary in &binaries.binaries {
- r_println!(
+ writeln!(
+ result,
" {:width$} `{}`",
binary.name.bright_yellow().bold(),
binary.path.display().to_string().italic(),
width = max_name_len
- );
+ )
+ .ok();
}
}
+ result
}
diff --git a/mling/src/proj_mgr/show_directories.rs b/mling/src/proj_mgr/show_directories.rs
index e84bf69..5bfb090 100644
--- a/mling/src/proj_mgr/show_directories.rs
+++ b/mling/src/proj_mgr/show_directories.rs
@@ -1,14 +1,15 @@
use colored::Colorize;
use mingling::{
- Groupped,
- macros::{chain, pack, r_println, renderer},
+ macros::{chain, pack, renderer},
+ Groupped, RenderResult,
};
use serde::Serialize;
+use std::io::Write as _;
use crate::{
- Next,
- proj_mgr::{EntryShowTargetDirectories, EntryShowWorkspaceDirectory, metadata::read_metadata},
+ proj_mgr::{metadata::read_metadata, EntryShowTargetDirectories, EntryShowWorkspaceDirectory},
res::ResManifestPath,
+ Next,
};
#[derive(Serialize, Groupped)]
@@ -46,11 +47,15 @@ pub fn handle_show_target_directory(
}
#[renderer]
-pub fn render_workspace_directory(prev: ResultWorkspaceDirectory) {
- r_println!("{}", prev.path.bright_cyan().bold());
+pub fn render_workspace_directory(prev: ResultWorkspaceDirectory) -> RenderResult {
+ let mut result = RenderResult::default();
+ writeln!(result, "{}", prev.path.bright_cyan().bold()).ok();
+ result
}
#[renderer]
-pub fn render_target_directory(prev: ResultTargetDirectory) {
- r_println!("{}", prev.path.bright_cyan().bold());
+pub fn render_target_directory(prev: ResultTargetDirectory) -> RenderResult {
+ let mut result = RenderResult::default();
+ writeln!(result, "{}", prev.path.bright_cyan().bold()).ok();
+ result
}