1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use crate::cli_wrapper;
use clap::ValueEnum;
use rudof_lib::formats::{QueryType, ResultQueryFormat};
use std::fmt::{Display, Formatter, Result};
cli_wrapper!(
QueryTypeCli,
QueryType,
{
Select,
Construct,
Ask,
Describe,
}
);
cli_wrapper!(
ResultQueryFormatCli,
ResultQueryFormat,
{
Internal,
Turtle,
NTriples,
JsonLd,
Json,
RdfXml,
Csv,
Markdown,
AsciiTable,
TriG,
N3,
NQuads,
}
);
/// Query dialect: which language `-q`/`--query` is written in.
///
/// No corresponding `rudof_lib` type exists (Cypher execution is CLI-only,
/// see `commands/query.rs`), so this is a plain enum rather than a
/// `cli_wrapper!`.
#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq, Default)]
#[clap(rename_all = "lower")]
pub enum QueryDialectCli {
/// SPARQL, run against the loaded RDF data or a SPARQL endpoint
#[default]
Sparql,
/// Cypher, run against a LadybugDB database (see `rudof connect`)
Cypher,
}
impl Display for QueryDialectCli {
fn fmt(&self, f: &mut Formatter) -> Result {
let val = self.to_possible_value().expect("no skipped variants");
write!(f, "{}", val.get_name())
}
}