aboutsummaryrefslogtreecommitdiff
path: root/mling/src/proj_mgr/show_directories.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mling/src/proj_mgr/show_directories.rs')
-rw-r--r--mling/src/proj_mgr/show_directories.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/mling/src/proj_mgr/show_directories.rs b/mling/src/proj_mgr/show_directories.rs
new file mode 100644
index 0000000..32020c9
--- /dev/null
+++ b/mling/src/proj_mgr/show_directories.rs
@@ -0,0 +1,55 @@
+use colored::Colorize;
+use mingling::{
+ Groupped,
+ macros::{chain, pack, r_println, renderer},
+};
+use serde::Serialize;
+
+use crate::{
+ EntryShowTargetDirectories, EntryShowWorkspaceDirectory, Next, metadata::read_metadata,
+ res::ResManifestPath,
+};
+
+#[derive(Serialize, Groupped)]
+pub struct ResultWorkspaceDirectory {
+ pub path: String,
+}
+
+#[derive(Serialize, Groupped)]
+pub struct ResultTargetDirectory {
+ pub path: String,
+}
+
+#[chain]
+pub fn handle_show_workspace_directory(
+ _args: EntryShowWorkspaceDirectory,
+ manifest_path: &ResManifestPath,
+) -> Next {
+ let metadata = read_metadata(manifest_path.resolved()).unwrap();
+ ResultWorkspaceDirectory {
+ path: metadata.workspace_root,
+ }
+ .to_render()
+}
+
+#[chain]
+pub fn handle_show_target_directory(
+ _args: EntryShowTargetDirectories,
+ manifest_path: &ResManifestPath,
+) -> Next {
+ let metadata = read_metadata(manifest_path.resolved()).unwrap();
+ ResultTargetDirectory {
+ path: metadata.target_directory,
+ }
+ .to_render()
+}
+
+#[renderer]
+pub fn render_workspace_directory(prev: ResultWorkspaceDirectory) {
+ r_println!("{}", prev.path.bright_cyan().bold());
+}
+
+#[renderer]
+pub fn render_target_directory(prev: ResultTargetDirectory) {
+ r_println!("{}", prev.path.bright_cyan().bold());
+}