Added tools, cleaned up main
This commit is contained in:
parent
439a67adc6
commit
4abc588ba0
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug executable 'khetamine'",
|
||||||
|
"cargo": {
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"--bin=khetamine",
|
||||||
|
"--package=khetamine"
|
||||||
|
],
|
||||||
|
"filter": {
|
||||||
|
"name": "khetamine",
|
||||||
|
"kind": "bin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug unit tests in executable 'khetamine'",
|
||||||
|
"cargo": {
|
||||||
|
"args": [
|
||||||
|
"test",
|
||||||
|
"--no-run",
|
||||||
|
"--bin=khetamine",
|
||||||
|
"--package=khetamine"
|
||||||
|
],
|
||||||
|
"filter": {
|
||||||
|
"name": "khetamine",
|
||||||
|
"kind": "bin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,6 +2,56 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ansi_term"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "2.33.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||||
|
dependencies = [
|
||||||
|
"ansi_term",
|
||||||
|
"atty",
|
||||||
|
"bitflags",
|
||||||
|
"strsim",
|
||||||
|
"textwrap",
|
||||||
|
"unicode-width",
|
||||||
|
"vec_map",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.1.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
@ -12,10 +62,17 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||||
name = "khetamine"
|
name = "khetamine"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"clap",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.104"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.30"
|
version = "1.0.30"
|
||||||
|
@ -71,6 +128,12 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.80"
|
version = "1.0.80"
|
||||||
|
@ -82,8 +145,51 @@ dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vec_map"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
|
@ -7,4 +7,5 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.130", features = ["derive"] }
|
serde = { version = "1.0.130", features = ["derive"] }
|
||||||
serde_json = "1.0.68"
|
serde_json = "1.0.68"
|
||||||
|
clap = "2.33.3"
|
92
src/main.rs
92
src/main.rs
|
@ -1,43 +1,35 @@
|
||||||
use std::env;
|
mod models {
|
||||||
|
pub mod board;
|
||||||
// mod models {
|
pub mod piece;
|
||||||
// pub mod board;
|
pub mod networking;
|
||||||
// pub mod piece;
|
|
||||||
// pub mod networking;
|
|
||||||
// }
|
|
||||||
|
|
||||||
fn print_help() {
|
|
||||||
println!("Ey fam, hmu with dat '--serve' or '--join <address>'")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_game() {
|
|
||||||
println!("OK");
|
|
||||||
}
|
}
|
||||||
|
use clap::{Arg, App, SubCommand};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let matches = App::new("Khetamine")
|
||||||
if (args.len() == 2) && ((args[1] == "--serve") | (args[1] == "serve")) {
|
.version("1.0")
|
||||||
|
.author("oysteikt, felixalb")
|
||||||
|
.about("Play Khet with your friends!")
|
||||||
|
.arg(Arg::with_name("serve")
|
||||||
|
.short("s")
|
||||||
|
.long("serve")
|
||||||
|
.help("Run as game server, your friend connects as client."))
|
||||||
|
.arg(Arg::with_name("connect")
|
||||||
|
.short("c")
|
||||||
|
.help("Connect to a server")
|
||||||
|
.value_name("ADRESS")
|
||||||
|
.takes_value(true)
|
||||||
|
.arg(Arg::with_name("v")
|
||||||
|
.short("v")
|
||||||
|
.multiple(true)
|
||||||
|
.help("Sets the level of verbosity"))
|
||||||
|
.subcommand(SubCommand::with_name("test")
|
||||||
|
.about("Runs various tests")
|
||||||
|
.version("1.3")
|
||||||
|
.author("felixalb"))
|
||||||
|
.get_matches();
|
||||||
|
|
||||||
//Start game server
|
println!("{}", matches);
|
||||||
println!("Serving!");
|
|
||||||
start_game();
|
|
||||||
|
|
||||||
} else if (args.len() == 3) && ((args[1] == "--join") | (args[1] == "join")) {
|
|
||||||
|
|
||||||
//Join game server
|
|
||||||
println!("Joining!");
|
|
||||||
start_game();
|
|
||||||
|
|
||||||
} else if (args.len() == 2) && (args[1] == "--help") {
|
|
||||||
|
|
||||||
print_help();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
println!("What do you mean with {:?}\n", args);
|
|
||||||
print_help();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// println!("{}", &serialize_move(models::networking::Action::Rotate {
|
// println!("{}", &serialize_move(models::networking::Action::Rotate {
|
||||||
// from: (2, 2),
|
// from: (2, 2),
|
||||||
|
@ -47,18 +39,16 @@ fn main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn serialize_move(action: models::networking::Action) -> String {
|
||||||
|
let serialized = serde_json::to_string(&action);
|
||||||
// fn serialize_move(action: models::networking::Action) -> str {
|
match serialized {
|
||||||
// let serialized = serde_json::to_string(&action);
|
Ok(s) => {
|
||||||
// match serialized {
|
// println!("{}", s);
|
||||||
// Ok(s) => {
|
return s;
|
||||||
// println!("OK: {}", s);
|
},
|
||||||
// return &s;
|
Err(_e) => {
|
||||||
// },
|
println!("Couldn't serialize...");
|
||||||
// Err(_e) => {
|
return String::from("");
|
||||||
// println!("Couldn't serialize...");
|
}
|
||||||
// return ("");
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
Loading…
Reference in New Issue