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:
Kiana Sheibani 2023-09-23 03:01:36 -04:00
parent 2c6587aca1
commit dd4f0838ab
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
14 changed files with 75 additions and 83 deletions

26
Cargo.lock generated
View file

@ -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"

View file

@ -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"

View file

@ -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();

View file

@ -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"

View file

@ -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");
}
}

View file

@ -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 ];
};

View file

@ -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
View 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());
}