Add option for output format
This commit is contained in:
parent
c953b465e9
commit
9f4b7946f5
@ -1,7 +1,7 @@
|
|||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub(crate) mod output;
|
pub mod output;
|
||||||
pub mod translate;
|
pub mod translate;
|
||||||
|
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -10,6 +10,10 @@ enum Command
|
|||||||
/// ASP input program (one or multiple files)
|
/// ASP input program (one or multiple files)
|
||||||
#[structopt(parse(from_os_str), required(true))]
|
#[structopt(parse(from_os_str), required(true))]
|
||||||
input: Vec<std::path::PathBuf>,
|
input: Vec<std::path::PathBuf>,
|
||||||
|
|
||||||
|
/// Output format (human-readable, tptp)
|
||||||
|
#[structopt(long, default_value = "human-readable")]
|
||||||
|
output_format: anthem::output::Format,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +25,12 @@ fn main()
|
|||||||
|
|
||||||
match command
|
match command
|
||||||
{
|
{
|
||||||
Command::VerifyProgram{input} =>
|
Command::VerifyProgram
|
||||||
|
{
|
||||||
|
input,
|
||||||
|
output_format,
|
||||||
|
}
|
||||||
|
=>
|
||||||
{
|
{
|
||||||
if let Err(error) = anthem::translate::verify_properties::translate(&input)
|
if let Err(error) = anthem::translate::verify_properties::translate(&input)
|
||||||
{
|
{
|
||||||
|
@ -1 +1,41 @@
|
|||||||
pub(crate) mod tptp;
|
pub(crate) mod tptp;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Format
|
||||||
|
{
|
||||||
|
HumanReadable,
|
||||||
|
TPTP,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct InvalidFormatError;
|
||||||
|
|
||||||
|
impl std::fmt::Debug for InvalidFormatError
|
||||||
|
{
|
||||||
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
|
{
|
||||||
|
write!(formatter, "invalid output format")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for InvalidFormatError
|
||||||
|
{
|
||||||
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
|
{
|
||||||
|
write!(formatter, "{:?}", self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for Format
|
||||||
|
{
|
||||||
|
type Err = InvalidFormatError;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err>
|
||||||
|
{
|
||||||
|
match s
|
||||||
|
{
|
||||||
|
"human-readable" => Ok(Format::HumanReadable),
|
||||||
|
"tptp" => Ok(Format::TPTP),
|
||||||
|
_ => Err(InvalidFormatError),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user