Fix list subcommand not printing multiline descriptions properly

This commit is contained in:
Filip Tibell 2023-06-08 11:31:26 +02:00
parent 42ab2da1ed
commit 0773dc024a
No known key found for this signature in database
3 changed files with 20 additions and 0 deletions

16
Cargo.lock generated
View file

@ -575,6 +575,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
[[package]]
name = "either"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]] [[package]]
name = "encode_unicode" name = "encode_unicode"
version = "0.3.6" version = "0.3.6"
@ -1042,6 +1048,15 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.6" version = "1.0.6"
@ -1179,6 +1194,7 @@ dependencies = [
"full_moon", "full_moon",
"futures-util", "futures-util",
"include_dir", "include_dir",
"itertools",
"lune", "lune",
"once_cell", "once_cell",
"regex", "regex",

View file

@ -34,6 +34,7 @@ tokio.workspace = true
anyhow = "1.0" anyhow = "1.0"
env_logger = "0.10" env_logger = "0.10"
itertools = "0.10"
clap = { version = "4.1", features = ["derive"] } clap = { version = "4.1", features = ["derive"] }
full_moon = { version = "0.17", features = ["roblox"] } full_moon = { version = "0.17", features = ["roblox"] }

View file

@ -6,6 +6,7 @@ use std::{
use anyhow::{anyhow, bail, Result}; use anyhow::{anyhow, bail, Result};
use console::style; use console::style;
use directories::UserDirs; use directories::UserDirs;
use itertools::Itertools;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
const LUNE_COMMENT_PREFIX: &str = "-->"; const LUNE_COMMENT_PREFIX: &str = "-->";
@ -178,6 +179,8 @@ pub fn parse_lune_description_from_file(contents: &str) -> Option<String> {
let unindented_lines = comment_lines let unindented_lines = comment_lines
.iter() .iter()
.map(|line| &line[shortest_indent..]) .map(|line| &line[shortest_indent..])
// Replace newlines with a single space inbetween instead
.interleave(std::iter::repeat(" ").take(comment_lines.len() - 1))
.collect(); .collect();
Some(unindented_lines) Some(unindented_lines)
} }