Move CLI crate to root of workspace
Somehow I missed that this was a thing you could do? It's a much cleaner organization, and it makes it so that you don't have to explicitly specify the crate to build.
This commit is contained in:
parent
2c6587aca1
commit
dd4f0838ab
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -107,19 +107,6 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cynic",
|
||||
"cynic-codegen",
|
||||
"dirs",
|
||||
"reqwest",
|
||||
"schema",
|
||||
"serde",
|
||||
"sqlite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "3.8.1"
|
||||
|
@ -389,6 +376,19 @@ dependencies = [
|
|||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ggelo"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cynic",
|
||||
"cynic-codegen",
|
||||
"dirs",
|
||||
"reqwest",
|
||||
"schema",
|
||||
"serde",
|
||||
"sqlite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.28.0"
|
||||
|
|
29
Cargo.toml
29
Cargo.toml
|
@ -1,5 +1,26 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"schema",
|
||||
"cli"
|
||||
]
|
||||
|
||||
[package]
|
||||
name = "ggelo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "ggelo"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
# GraphQL schema
|
||||
schema.path = "schema"
|
||||
|
||||
# API access
|
||||
cynic = { version = "3.2", features = ["http-reqwest-blocking"] }
|
||||
reqwest = "0.11"
|
||||
serde = "1.0"
|
||||
|
||||
# Local file manipulation
|
||||
dirs = "5.0"
|
||||
sqlite = "0.31"
|
||||
|
||||
[build-dependencies]
|
||||
cynic-codegen = "3.2"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn main() {
|
||||
cynic_codegen::register_schema("startgg")
|
||||
.from_sdl_file("../schema/src/startgg.graphql")
|
||||
.from_sdl_file("schema/startgg.graphql")
|
||||
.unwrap()
|
||||
.as_default()
|
||||
.unwrap();
|
|
@ -1,24 +0,0 @@
|
|||
[package]
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "ggelo"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
# GraphQL schema
|
||||
schema.path = "../schema"
|
||||
|
||||
# API access
|
||||
cynic = { version = "3.2", features = ["http-reqwest-blocking"] }
|
||||
reqwest = "0.11"
|
||||
serde = "1.0"
|
||||
|
||||
# Local file manipulation
|
||||
dirs = "5.0"
|
||||
sqlite = "0.31"
|
||||
|
||||
[build-dependencies]
|
||||
cynic-codegen = "3.2"
|
|
@ -1,39 +0,0 @@
|
|||
#![feature(iterator_try_collect)]
|
||||
|
||||
mod queries;
|
||||
use queries::*;
|
||||
|
||||
mod datasets;
|
||||
|
||||
fn main() {
|
||||
let mut config_dir = dirs::config_dir().unwrap();
|
||||
config_dir.push("ggelo");
|
||||
let auth_key = get_auth_key(&config_dir).expect("Could not find authorization key");
|
||||
|
||||
if let Some(response) = run_query::<TournamentSets, _>(
|
||||
TournamentSetsVars {
|
||||
last_query: Timestamp(1),
|
||||
game_id: VideogameId(1386),
|
||||
country: None,
|
||||
state: Some("GA"),
|
||||
},
|
||||
&auth_key,
|
||||
) {
|
||||
println!("Succeeded");
|
||||
for tournament in response {
|
||||
println!("Tournament: {}", tournament.name);
|
||||
for set in tournament.sets {
|
||||
println!(
|
||||
"Winner: {}",
|
||||
if set.winner {
|
||||
set.player2.0
|
||||
} else {
|
||||
set.player1.0
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("Invalid GraphQL response");
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@
|
|||
pname = "ggelo";
|
||||
version = "0.1.0";
|
||||
src = craneLib.path ./.;
|
||||
cargoBuildFlags = "-p cli";
|
||||
buildInputs = [ pkgs.openssl pkgs.sqlite ];
|
||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn main() {
|
||||
cynic_codegen::register_schema("startgg")
|
||||
.from_sdl_file("src/startgg.graphql")
|
||||
.from_sdl_file("startgg.graphql")
|
||||
.unwrap()
|
||||
.as_default()
|
||||
.unwrap();
|
||||
|
|
35
src/main.rs
Normal file
35
src/main.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
#![feature(iterator_try_collect)]
|
||||
|
||||
use std::io::{self, Write};
|
||||
|
||||
mod queries;
|
||||
use queries::*;
|
||||
mod datasets;
|
||||
use datasets::*;
|
||||
|
||||
fn main() {
|
||||
let mut config_dir = dirs::config_dir().unwrap();
|
||||
config_dir.push("ggelo");
|
||||
|
||||
let path = dataset_path(&config_dir, "test");
|
||||
let connection = open_dataset(&path).unwrap();
|
||||
|
||||
let set_data = SetData {
|
||||
teams: vec![
|
||||
vec![PlayerData {
|
||||
id: PlayerId(1),
|
||||
name: Some("player1".to_owned()),
|
||||
prefix: None,
|
||||
}],
|
||||
vec![PlayerData {
|
||||
id: PlayerId(2),
|
||||
name: Some("player2".to_owned()),
|
||||
prefix: None,
|
||||
}],
|
||||
],
|
||||
winner: 0,
|
||||
};
|
||||
|
||||
update_from_set(&connection, set_data.clone()).unwrap();
|
||||
println!("{:?}", get_ratings(&connection, &set_data.teams).unwrap());
|
||||
}
|
Loading…
Reference in a new issue