mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-04-20 19:03:08 +01:00
Changes: Separate cli flags and put them in their own module. Add a rustfmt configuration file for grouping imports into crates (so we dont have to do this manually, and it seems we were already doing it manually so might as well) Use comments to describe cli flags instead of using ugly syntax (they both work the same but one is less ugly and more readable) Add a --mouse flag to enable mouse interaction (mouse interaction is now off by default) Add a --bypass-root flag to disable the annoying popup when you run the utility as root Fix an issue where you can't reach the bottom of the list in a subdir (i also reduced the nesting in those functions as well for readability) Add help feature to clap dependency to enable --help / -h Add usage feature to clap dependency to enable usage example when running with --help / -h Remove CLI arg examples from readme, and add instructions on how to view them on CLI to prevent it from bloating up the readme
58 lines
1.8 KiB
Rust
58 lines
1.8 KiB
Rust
use std::fs;
|
|
|
|
use linutil_core::Command;
|
|
|
|
use crate::{path, DynError};
|
|
|
|
pub const USER_GUIDE: &str = "userguide.md";
|
|
|
|
pub fn userguide() -> Result<String, DynError> {
|
|
let mut md = String::new();
|
|
md.push_str("<!-- THIS FILE IS GENERATED BY cargo xtask docgen -->\n# Walkthrough\n");
|
|
|
|
let tabs = linutil_core::get_tabs(false);
|
|
|
|
for tab in tabs {
|
|
#[cfg(debug_assertions)]
|
|
println!("Tab: {}", tab.name);
|
|
|
|
md.push_str(&format!("\n## {}\n\n", tab.name));
|
|
|
|
for entry in tab.tree {
|
|
if entry.command == Command::None {
|
|
#[cfg(debug_assertions)]
|
|
println!(" Directory: {}", entry.name);
|
|
|
|
if entry.name != "root" {
|
|
md.push_str(&format!("\n### {}\n\n", entry.name));
|
|
}
|
|
|
|
/* let current_dir = &entry.name;
|
|
|
|
if *current_dir != "root".to_string() {
|
|
md.push_str(&format!(
|
|
"\n<details><summary>{}</summary>\n\n",
|
|
current_dir
|
|
));
|
|
} */ // Commenting this for now, might be a good idea later
|
|
} else if !entry.description.is_empty() {
|
|
#[cfg(debug_assertions)]
|
|
println!(" Entry: {}", entry.name);
|
|
#[cfg(debug_assertions)]
|
|
println!(" Description: {}", entry.description);
|
|
|
|
md.push_str(&format!("- **{}**: {}\n", entry.name, entry.description));
|
|
} /* else {
|
|
md.push_str(&format!("- **{}**\n", entry.name));
|
|
} */ // https://github.com/ChrisTitusTech/linutil/pull/753
|
|
}
|
|
}
|
|
|
|
Ok(md)
|
|
}
|
|
|
|
pub fn write(file: &str, data: &str) {
|
|
let path = path::docs().join(file);
|
|
fs::write(path, data).unwrap_or_else(|_| panic!("Could not write to {}", file));
|
|
}
|