cleaner config (no error if cache is cleaned
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
This commit is contained in:
parent
e26e7df913
commit
4fb3733311
27
src/main.rs
27
src/main.rs
@ -27,10 +27,11 @@ use tracing_subscriber::fmt;
|
|||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
|
#[group(required = true, args(&["config", "clear_cache"]))]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Path to the config of a law text
|
/// Path to the config of a law text
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
config: String,
|
config: Option<String>,
|
||||||
|
|
||||||
/// Parses a single paragraph (for debugging, e.g. https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR40217849/NOR40217849.xml)
|
/// Parses a single paragraph (for debugging, e.g. https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR40217849/NOR40217849.xml)
|
||||||
/// Conflicts with `config` (either parse full law XOR single paragraph)
|
/// Conflicts with `config` (either parse full law XOR single paragraph)
|
||||||
@ -41,6 +42,7 @@ struct Args {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
clear_cache: bool,
|
clear_cache: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
@ -53,17 +55,18 @@ fn main() {
|
|||||||
if let Err(e) = clear_cache() {
|
if let Err(e) = clear_cache() {
|
||||||
println!("Failed to clear cache: {e:?}");
|
println!("Failed to clear cache: {e:?}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(par_url) = &args.par_url {
|
|
||||||
let (_, mut builder, parser) = Config::load(&args.config).unwrap();
|
|
||||||
builder.add_classifier(Classifier::new("always-true", Arc::new(always_true)));
|
|
||||||
// builder.new_header("initial");
|
|
||||||
parser.parse(par_url, &mut builder).unwrap();
|
|
||||||
let law: Law = builder.into();
|
|
||||||
println!("{law:?}");
|
|
||||||
} else {
|
} else {
|
||||||
let law = Law::from_config(&args.config).unwrap();
|
let config = &args.config.unwrap(); // ok, checked with clap
|
||||||
law.to_md();
|
if let Some(par_url) = &args.par_url {
|
||||||
|
let (_, mut builder, parser) = Config::load(config).unwrap();
|
||||||
|
builder.add_classifier(Classifier::new("always-true", Arc::new(always_true)));
|
||||||
|
// builder.new_header("initial");
|
||||||
|
parser.parse(par_url, &mut builder).unwrap();
|
||||||
|
let law: Law = builder.into();
|
||||||
|
println!("{law:?}");
|
||||||
|
} else {
|
||||||
|
let law = Law::from_config(config).unwrap();
|
||||||
|
law.to_md();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ fn fetch(url: &str) -> Result<String, Error> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::{config::Config, overview};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
0
update_laws.sh
Normal file → Executable file
0
update_laws.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user