Move CharacterSb to lib
This commit is contained in:
36
src/character.rs
Normal file
36
src/character.rs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub struct CharacterSb {
|
||||||
|
pub name: String,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub kind: String,
|
||||||
|
pub level: serde_json::Value,
|
||||||
|
#[serde(rename = "trait")]
|
||||||
|
pub traits: Vec<String>,
|
||||||
|
pub skill_markdown: Option<String>,
|
||||||
|
pub hp_raw: String,
|
||||||
|
pub perception: i32,
|
||||||
|
pub sense_markdown: String,
|
||||||
|
pub strength: i32,
|
||||||
|
pub dexterity: i32,
|
||||||
|
pub constitution: i32,
|
||||||
|
pub intelligence: i32,
|
||||||
|
pub wisdom: i32,
|
||||||
|
pub charisma: i32,
|
||||||
|
pub ac: i32,
|
||||||
|
pub fortitude_save: i32,
|
||||||
|
pub reflex_save: i32,
|
||||||
|
pub will_save: i32,
|
||||||
|
pub immunity_markdown: Option<String>,
|
||||||
|
pub resistance_markdown: Option<String>,
|
||||||
|
pub weakness_markdown: Option<String>,
|
||||||
|
pub speed_markdown: String,
|
||||||
|
pub markdown: String,
|
||||||
|
/// If this is a legacy creature that has been remastered, this will be `Some`
|
||||||
|
pub remaster_id: Option<Vec<String>>,
|
||||||
|
/// If this is a remastered creature, this will be `Some`
|
||||||
|
pub legacy_id: Option<Vec<String>>,
|
||||||
|
}
|
||||||
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod character;
|
||||||
37
src/main.rs
37
src/main.rs
@@ -1,7 +1,7 @@
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use nethys_to_obsidian::character::CharacterSb;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::Deserialize;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{Read, stdin};
|
use std::io::{Read, stdin};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -14,41 +14,6 @@ struct Args {
|
|||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Deserialize, Debug)]
|
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
struct CharacterSb {
|
|
||||||
name: String,
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
kind: String,
|
|
||||||
level: serde_json::Value,
|
|
||||||
#[serde(rename = "trait")]
|
|
||||||
traits: Vec<String>,
|
|
||||||
skill_markdown: Option<String>,
|
|
||||||
hp_raw: String,
|
|
||||||
perception: i32,
|
|
||||||
sense_markdown: String,
|
|
||||||
strength: i32,
|
|
||||||
dexterity: i32,
|
|
||||||
constitution: i32,
|
|
||||||
intelligence: i32,
|
|
||||||
wisdom: i32,
|
|
||||||
charisma: i32,
|
|
||||||
ac: i32,
|
|
||||||
fortitude_save: i32,
|
|
||||||
reflex_save: i32,
|
|
||||||
will_save: i32,
|
|
||||||
immunity_markdown: Option<String>,
|
|
||||||
resistance_markdown: Option<String>,
|
|
||||||
weakness_markdown: Option<String>,
|
|
||||||
speed_markdown: String,
|
|
||||||
markdown: String,
|
|
||||||
/// If this is a legacy creature that has been remastered, this will be `Some`
|
|
||||||
remaster_id: Option<Vec<String>>,
|
|
||||||
/// If this is a remastered creature, this will be `Some`
|
|
||||||
legacy_id: Option<Vec<String>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_val(v: &serde_json::Value) -> String {
|
fn format_val(v: &serde_json::Value) -> String {
|
||||||
if v.is_string() {
|
if v.is_string() {
|
||||||
v.as_str().unwrap_or("").to_string()
|
v.as_str().unwrap_or("").to_string()
|
||||||
|
|||||||
Reference in New Issue
Block a user