diff options
author | tom barrett <spalf0@gmail.com> | 2019-02-10 11:52:04 -0600 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-02-10 11:52:04 -0600 |
commit | 6a906ce663935e37d6dd79a2e2e31fb07ca7c2af (patch) | |
tree | 0fae3c321922c531c2a066d7aca096ef59bddd7d | |
parent | f617213b4a48d73acd245580f8551a7c37ce9ad8 (diff) |
cleaned up ideas and added the ability to do client <module>
-rw-r--r-- | Cargo.lock | 63 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | README.md | 22 | ||||
-rw-r--r-- | src/bin/client.rs | 47 |
4 files changed, 115 insertions, 18 deletions
@@ -1,4 +1,22 @@ [[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "autocfg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -9,6 +27,20 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "clap" +version = "2.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -219,6 +251,7 @@ dependencies = [ name = "space" version = "0.1.0" dependencies = [ + "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", @@ -228,6 +261,11 @@ dependencies = [ ] [[package]] +name = "strsim" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "syn" version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -248,6 +286,14 @@ dependencies = [ ] [[package]] +name = "textwrap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -256,11 +302,21 @@ dependencies = [ ] [[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "winapi" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -280,8 +336,11 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" @@ -308,10 +367,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" "checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" @@ -11,3 +11,4 @@ serde_json = "1.0" termion = "*" rand = "0.6" toml = "0.4" +clap = "2" @@ -1,18 +1,28 @@ space ideas + +modules - construction module (upgrade ship, create stations which perform module functions better and cheaper) - weapons modules - communication module (various ranges of tx/rx, encryption of messages) -- tiers of minerals, modules -- pretty dashboard -- better client cli parsing (e.g. ability to do ./client navigation) - some sort of energy / fuel mechanic for all processes, solar panels if stranded -- server ability to quit and import/export all data +- bookmarking objects (e.g. stations, estimates position & velocity outside navigation) +- hacking modules to disable other modules +- some sort of armor / shield module + +world +- tiers of minerals, modules - collisions - figure how position floats overflow and how to improve it - figure out spawning - figure out some sort of dynamic zone system - figure out other bodies (planets, suns, n-body simulation?) -- bookmarking objects (e.g. stations, estimates position & velocity outside navigation) -- maybe create interface with masses data + +nice to haves +- pretty dashboard +- more cli parsing stuff +- website with leaderboards, documentation, account stuff for main server +- open server api with documentation so people can develop their own clients +- server ability to quit and import/export all current data +- have something like lightshope donation page diff --git a/src/bin/client.rs b/src/bin/client.rs index ef5faff..517076f 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,3 +1,4 @@ +extern crate clap; extern crate serde_json; extern crate space; extern crate toml; @@ -5,6 +6,7 @@ extern crate toml; #[macro_use] extern crate serde_derive; +use clap::{App, SubCommand}; use std::fs::File; use std::io; use std::io::prelude::*; @@ -32,6 +34,16 @@ fn main() { let server; let mut name = String::new(); + let matches = App::new("space") + .subcommand(SubCommand::with_name("mining")) + .subcommand(SubCommand::with_name("engines")) + .subcommand(SubCommand::with_name("refinery")) + .subcommand(SubCommand::with_name("dashboard")) + .subcommand(SubCommand::with_name("navigation")) + .subcommand(SubCommand::with_name("tractorbeam")) + .subcommand(SubCommand::with_name("construction")) + .get_matches(); + match File::open(".space") { Ok(mut config_file) => { let mut config_string = String::new(); @@ -65,17 +77,28 @@ fn main() { buff_r.read_line(&mut recv).unwrap(); let modules: Vec<ModuleType> = serde_json::from_str(&recv.replace("\n", "")).unwrap(); - println!("Choose your module:"); - for (i, module) in modules.iter().enumerate() { - println!("{}) {:?}", i, module); - } - - let mut choice = String::new(); - io::stdin().read_line(&mut choice).expect("Failed"); - let module_type = modules - .into_iter() - .nth(choice.replace("\n", "").parse::<usize>().unwrap()) - .unwrap(); + let module_type = match matches.subcommand_name() { + Some("mining") => ModuleType::Mining, + Some("engines") => ModuleType::Engines, + Some("refinery") => ModuleType::Refinery, + Some("dashboard") => ModuleType::Dashboard, + Some("navigation") => ModuleType::Navigation, + Some("tractorbeam") => ModuleType::Tractorbeam, + Some("construction") => ModuleType::Construction, + _ => { + println!("Choose your module:"); + for (i, module) in modules.iter().enumerate() { + println!("{}) {:?}", i, module); + } + + let mut choice = String::new(); + io::stdin().read_line(&mut choice).expect("Failed"); + modules + .into_iter() + .nth(choice.replace("\n", "").parse::<usize>().unwrap()) + .unwrap() + } + }; let send = serde_json::to_string(&module_type).unwrap() + "\n"; stream.write_all(send.as_bytes()).unwrap(); @@ -85,8 +108,8 @@ fn main() { ModuleType::Mining => client_mining(stream, buff_r), ModuleType::Engines => client_engines(stream, buff_r), ModuleType::Refinery => client_refinery(stream, buff_r), - ModuleType::Navigation => client_navigation(name, stream, buff_r), ModuleType::Tractorbeam => client_tractorbeam(stream, buff_r), ModuleType::Construction => client_construction(stream, buff_r), + ModuleType::Navigation => client_navigation(name, stream, buff_r), } } |