Upgrades to Clap 3

pull/190/head
Tpt 3 years ago
parent 8ebd52882b
commit df1478e931
  1. 168
      Cargo.lock
  2. 2
      server/Cargo.toml
  3. 89
      server/src/main.rs
  4. 2
      testsuite/Cargo.toml
  5. 21
      testsuite/src/main.rs

168
Cargo.lock generated

@ -33,9 +33,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.51"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
[[package]]
name = "atty"
@ -69,7 +69,7 @@ dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"clap",
"clap 2.34.0",
"env_logger",
"lazy_static",
"lazycell",
@ -169,12 +169,42 @@ dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap",
"strsim 0.8.0",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d17bf219fcd37199b9a29e00ba65dfb8cd5b2688b7297ec14ff829c40ac50ca9"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim 0.10.0",
"termcolor",
"textwrap 0.14.2",
]
[[package]]
name = "clap_derive"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1b9752c030a14235a0bd5ef3ad60a1dcac8468c30921327fc8af36b20c790b9"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
@ -218,7 +248,7 @@ checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
dependencies = [
"atty",
"cast",
"clap",
"clap 2.34.0",
"criterion-plot",
"csv",
"itertools",
@ -439,6 +469,15 @@ dependencies = [
"ahash",
]
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
@ -477,6 +516,16 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "indexmap"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "indoc"
version = "0.3.6"
@ -658,9 +707,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "mownstr"
version = "0.1.1"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "342a407881dbd200f13a08ff8a5413232e035ed7ba56dba8c81137e3afce4f84"
checksum = "76aacdf8f9850a9db34e33e35abfc17a29b9577d0eb2cbfaeb734662cacca5b3"
[[package]]
name = "native-tls"
@ -702,9 +751,9 @@ dependencies = [
[[package]]
name = "num_cpus"
version = "1.13.0"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
dependencies = [
"hermit-abi",
"libc",
@ -755,6 +804,15 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]]
name = "oxhttp"
version = "0.1.3"
@ -818,7 +876,7 @@ dependencies = [
name = "oxigraph_server"
version = "0.3.0-dev"
dependencies = [
"clap",
"clap 3.0.0",
"oxhttp",
"oxigraph",
"oxiri",
@ -831,7 +889,7 @@ name = "oxigraph_testsuite"
version = "0.3.0-dev"
dependencies = [
"anyhow",
"clap",
"clap 3.0.0",
"criterion",
"oxigraph",
"text-diff",
@ -978,9 +1036,33 @@ dependencies = [
[[package]]
name = "ppv-lite86"
version = "0.2.15"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]]
name = "proc-macro-hack"
@ -990,9 +1072,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro2"
version = "1.0.34"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
"unicode-xid",
]
@ -1065,9 +1147,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.10"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
dependencies = [
"proc-macro2",
]
@ -1432,9 +1514,9 @@ checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
[[package]]
name = "sophia_api"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acd999315a30142ca47a790fbad5dc646900a281b5607704bd8832f3711a1d18"
checksum = "e45365d668e8b7c4841094db3713a747a4f40f8db40f8b84b13303d2890ad9fd"
dependencies = [
"lazy_static",
"mownstr",
@ -1446,9 +1528,9 @@ dependencies = [
[[package]]
name = "sophia_iri"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6211a37cce10cac8d690a8bf2e8c1eef14963acd6f872df1cd527e7852278fa8"
checksum = "85b1a4e06de36c45e0b55ed1b061acc65c1d59eeeaf73baa1c244917f4cca942"
dependencies = [
"lazy_static",
"mownstr",
@ -1478,11 +1560,17 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.82"
version = "1.0.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b"
dependencies = [
"proc-macro2",
"quote",
@ -1541,6 +1629,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
[[package]]
name = "thiserror"
version = "1.0.30"
@ -1598,9 +1692,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "typenum"
version = "1.14.0"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-bidi"
@ -1617,6 +1711,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
version = "0.1.9"
@ -1667,9 +1767,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
@ -1854,18 +1954,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "zstd"
version = "0.9.0+zstd.1.5.0"
version = "0.9.1+zstd.1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07749a5dc2cb6b36661290245e350f15ec3bbb304e493db54a1d354480522ccd"
checksum = "538b8347df9257b7fbce37677ef7535c00a3c7bf1f81023cc328ed7fe4b41de8"
dependencies = [
"zstd-safe",
]
[[package]]
name = "zstd-safe"
version = "4.1.1+zstd.1.5.0"
version = "4.1.2+zstd.1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c91c90f2c593b003603e5e0493c837088df4469da25aafff8bce42ba48caf079"
checksum = "9fb4cfe2f6e6d35c5d27ecd9d256c4b6f7933c4895654917460ec56c29336cc1"
dependencies = [
"libc",
"zstd-sys",
@ -1873,9 +1973,9 @@ dependencies = [
[[package]]
name = "zstd-sys"
version = "1.6.1+zstd.1.5.0"
version = "1.6.2+zstd.1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "615120c7a2431d16cf1cf979e7fc31ba7a5b5e5707b29c8a99e5dbf8a8392a33"
checksum = "2daf2f248d9ea44454bfcb2516534e8b8ad2fc91bf818a1885495fc42bc8ac9f"
dependencies = [
"cc",
"libc",

@ -13,7 +13,7 @@ edition = "2021"
[dependencies]
oxhttp = { version = "0.1", features = ["native-tls"] }
clap = "2"
clap = { version = "3", features = ["derive"] }
oxigraph = { version = "0.3.0-dev", path = "../lib", features = ["http_client"] }
rand = "0.8"
url = "2"

@ -9,7 +9,7 @@
unused_qualifications
)]
use clap::{crate_version, App, AppSettings, Arg, SubCommand};
use clap::{Parser, Subcommand};
use oxhttp::model::{Body, HeaderName, HeaderValue, Request, Response, Status};
use oxhttp::Server;
use oxigraph::io::{DatasetFormat, DatasetSerializer, GraphFormat, GraphSerializer};
@ -22,6 +22,7 @@ use std::cell::RefCell;
use std::cmp::min;
use std::fs::File;
use std::io::{self, BufReader, ErrorKind, Read, Write};
use std::path::PathBuf;
use std::rc::Rc;
use std::str::FromStr;
use std::thread::{spawn, JoinHandle};
@ -33,53 +34,45 @@ const HTTP_TIMEOUT: Duration = Duration::from_secs(60);
const HTML_ROOT_PAGE: &str = include_str!("../templates/query.html");
const LOGO: &str = include_str!("../logo.svg");
#[derive(Parser)]
#[clap(about, author, version)]
/// Oxigraph SPARQL server
struct Args {
/// Directory in which persist the data
#[clap(short, long, parse(from_os_str))]
location: Option<PathBuf>,
#[clap(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
/// Start Oxigraph HTTP server
Serve {
/// Host and port to listen to
#[clap(short, long, default_value = "localhost:7878")]
bind: String,
},
/// Bulk loads file(s) into the store
Load {
/// file(s) to load
#[clap(short, long)]
file: Vec<String>,
},
}
pub fn main() -> std::io::Result<()> {
let matches = App::new("Oxigraph SPARQL server")
.version(crate_version!())
.arg(
Arg::with_name("location")
.short("l")
.long("location")
.help("Directory in which persist the data")
.takes_value(true),
)
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
SubCommand::with_name("serve")
.about("Start Oxigraph HTTP server")
.arg(
Arg::with_name("bind")
.short("b")
.long("bind")
.help("Host and port to listen to")
.default_value("localhost:7878")
.takes_value(true),
),
)
.subcommand(
SubCommand::with_name("load")
.about("Bulk loads a file into the store")
.arg(
Arg::with_name("file")
.short("f")
.long("file")
.help("The file to load")
.takes_value(true)
.multiple(true)
.required(true),
),
)
.get_matches();
let matches = Args::parse();
let store = if let Some(path) = matches.value_of_os("location") {
let store = if let Some(path) = &matches.location {
Store::open(path)
} else {
Store::new()
}?;
match matches.subcommand() {
("load", Some(submatches)) => {
let handles = submatches.values_of("file").unwrap().into_iter().map(|file| {
match matches.command {
Command::Load { file } => {
let handles = file.iter().map(|file| {
let store = store.clone();
let file = file.to_string();
spawn(move || {
@ -105,8 +98,7 @@ pub fn main() -> std::io::Result<()> {
store.optimize()?;
Ok(())
}
("serve", Some(submatches)) => {
let bind = submatches.value_of("bind").unwrap();
Command::Serve { bind } => {
let mut server = Server::new(move |request| handle_request(request, store.clone()));
server.set_global_timeout(HTTP_TIMEOUT);
server
@ -116,10 +108,6 @@ pub fn main() -> std::io::Result<()> {
server.listen(bind)?;
Ok(())
}
(s, _) => {
eprintln!("Not supported subcommand: '{}'", s);
Ok(())
}
}
}
@ -1508,4 +1496,11 @@ mod tests {
assert_eq!(response.status(), expected_status, "Error message: {}", buf);
}
}
#[test]
fn clap_debug() {
use clap::IntoApp;
Args::into_app().debug_assert()
}
}

@ -13,7 +13,7 @@ publish = false
[dependencies]
anyhow = "1"
clap = "2"
clap = "3"
time = { version = "0.3", features = ["formatting"] }
oxigraph = { version = "0.3.0-dev", path="../lib" }
text-diff = "0.4"

@ -1,26 +1,25 @@
use anyhow::Result;
use clap::{App, Arg};
use clap::Parser;
use oxigraph_testsuite::evaluator::TestEvaluator;
use oxigraph_testsuite::manifest::TestManifest;
use oxigraph_testsuite::parser_evaluator::register_parser_tests;
use oxigraph_testsuite::report::build_report;
use oxigraph_testsuite::sparql_evaluator::register_sparql_tests;
#[derive(Parser)]
/// Oxigraph testsuite runner
struct Args {
/// URI of the testsuite manifest(s) to run
manifest: Vec<String>,
}
fn main() -> Result<()> {
let matches = App::new("Oxigraph testsuite runner")
.arg(
Arg::with_name("manifest")
.help("URI of the testsuite manifest to run")
.takes_value(true)
.multiple(true)
.required(true),
)
.get_matches();
let matches = Args::parse();
let mut evaluator = TestEvaluator::default();
register_parser_tests(&mut evaluator);
register_sparql_tests(&mut evaluator);
let manifest = TestManifest::new(matches.values_of("manifest").unwrap());
let manifest = TestManifest::new(matches.manifest);
let results = evaluator.evaluate(manifest)?;
print!("{}", build_report(results));
Ok(())

Loading…
Cancel
Save