Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 10, 2024
1 parent 596d35b commit b58d424
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/parse/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use indexmap::IndexMap;
use kdl::{KdlDocument, KdlEntry, KdlNode};
use kdl::{KdlDocument, KdlEntry, KdlNode, KdlValue};
use serde::Serialize;

use crate::error::UsageErr;
Expand Down Expand Up @@ -211,24 +211,26 @@ impl From<&SpecCommand> for KdlNode {
.push(KdlEntry::new_prop("help", help.clone()));
}
if let Some(help) = &cmd.long_help {
node.entries_mut()
.push(KdlEntry::new_prop("long_help", help.clone()));
let v = KdlValue::RawString(help.clone());
node.entries_mut().push(KdlEntry::new_prop("long_help", v));
}
if let Some(help) = &cmd.before_help {
node.entries_mut()
.push(KdlEntry::new_prop("before_help", help.clone()));
}
if let Some(help) = &cmd.before_long_help {
let v = KdlValue::RawString(help.clone());
node.entries_mut()
.push(KdlEntry::new_prop("before_long_help", help.clone()));
.push(KdlEntry::new_prop("before_long_help", v));
}
if let Some(help) = &cmd.after_help {
node.entries_mut()
.push(KdlEntry::new_prop("after_help", help.clone()));
}
if let Some(help) = &cmd.after_long_help {
let v = KdlValue::RawString(help.clone());
node.entries_mut()
.push(KdlEntry::new_prop("after_long_help", help.clone()));
.push(KdlEntry::new_prop("after_long_help", v));
}
for flag in &cmd.flags {
let children = node.children_mut().get_or_insert_with(KdlDocument::new);
Expand Down
7 changes: 5 additions & 2 deletions src/parse/flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::hash::Hash;
use std::str::FromStr;

use itertools::Itertools;
use kdl::{KdlDocument, KdlEntry, KdlNode};
use kdl::{KdlDocument, KdlEntry, KdlNode, KdlValue};
use serde::Serialize;

use crate::error::UsageErr::InvalidFlag;
Expand Down Expand Up @@ -100,7 +100,10 @@ impl From<&SpecFlag> for KdlNode {
node.push(KdlEntry::new_prop("help", desc.clone()));
}
if let Some(desc) = &flag.long_help {
node.push(KdlEntry::new_prop("long_help", desc.clone()));
node.push(KdlEntry::new_prop(
"long_help",
KdlValue::RawString(desc.clone()),
));
}
if flag.required {
node.push(KdlEntry::new_prop("required", true));
Expand Down
7 changes: 5 additions & 2 deletions src/parse/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::{Display, Formatter};
use std::iter::once;
use std::path::Path;

use kdl::{KdlDocument, KdlEntry, KdlNode};
use kdl::{KdlDocument, KdlEntry, KdlNode, KdlValue};
use serde::Serialize;
use xx::file;

Expand Down Expand Up @@ -121,6 +121,9 @@ impl Spec {
if !other.config.is_empty() {
self.config.merge(&other.config);
}
if !other.complete.is_empty() {
self.complete.extend(other.complete);
}
self.cmd.merge(other.cmd);
}
}
Expand Down Expand Up @@ -175,7 +178,7 @@ impl Display for Spec {
}
if let Some(long_about) = &self.long_about {
let mut node = KdlNode::new("long_about");
node.push(KdlEntry::new(long_about.clone()));
node.push(KdlEntry::new(KdlValue::RawString(long_about.clone())));
nodes.push(node);
}
if !self.usage.is_empty() {
Expand Down

0 comments on commit b58d424

Please sign in to comment.