Skip to content

Commit

Permalink
Cleanup and formatting to make everything stable; v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHelianthicusDoe committed Dec 31, 2019
1 parent 34e05c7 commit b2cff1e
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 179 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Cargo.lock

# Stray things
*.txt
build.sh
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shticker_book_unwritten"
version = "0.6.1"
version = "1.0.0"
authors = ["Dr. Jonathan Helianthicus Doe, IV <[email protected]>"]
edition = "2018"
description = "Minimal CLI launcher for the Toontown Rewritten MMORPG"
Expand All @@ -14,7 +14,7 @@ license = "GPL-3.0-or-later"
[dependencies]
bzip2 = "0.3.3"
rpassword = "4.0.3"
serde = { version = "1.0.103", features = ["derive"] }
serde = { version = "1.0.104", features = ["derive"] }
serde_json = "1.0.44"
sha-1 = "0.8.1"

Expand All @@ -24,7 +24,7 @@ default-features = false
features = ["suggestions", "vec_map"]

[dependencies.reqwest]
version = "0.10.0-alpha.2"
version = "0.10.0"
features = ["blocking", "default-tls"]

[profile.release]
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![crates.io](https://img.shields.io/crates/v/shticker_book_unwritten)](https://crates.io/crates/shticker_book_unwritten)
[![GPL v3+](https://img.shields.io/badge/license-GNU%20GPL%20v3%2B-bd0000)](./LICENSE)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
[![minimum supported rust version 1.39.0](https://img.shields.io/badge/rustc-%3E%3D1.39.0-dea584)](https://rustup.rs/)
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/JonathanHelianthicusDoe/shticker_book_unwritten)](https://github.com/JonathanHelianthicusDoe/shticker_book_unwritten)

![shticker\_book\_unwritten logo](./img/shticker_book_unwritten_256x256.png)
Expand All @@ -16,6 +17,9 @@ Currently builds and functions on GNU/Linux, Windows NT (using the MSVC
toolchain), and macOS (be sure to allow Terminal the ability to monitor
inputs).

**Mirror:**
<https://codeberg.org/JonathanHelianthicusDoe/shticker_book_unwritten>

## Installing

### From pre-compiled binary
Expand All @@ -25,7 +29,8 @@ You can get pre-compiled binaries from [the releases page][releases] on GitHub.
### From [crates.io](https://crates.io/)

Requires a distribution of [Rust](https://www.rust-lang.org/)/cargo, which you
can get from [rustup](https://rustup.rs/).
can get from [rustup](https://rustup.rs/). The minimum supported version of
rustc is 1.39.0.

```bash
cargo install shticker_book_unwritten
Expand All @@ -41,7 +46,8 @@ cargo install -f shticker_book_unwritten
### From GitHub git repository

Requires a distribution of [Rust](https://www.rust-lang.org/)/cargo, which you
can get from [rustup](https://rustup.rs/).
can get from [rustup](https://rustup.rs/). The minimum supported version of
rustc is 1.39.0.

```bash
git clone https://github.com/JonathanHelianthicusDoe/shticker_book_unwritten.git
Expand Down Expand Up @@ -80,12 +86,17 @@ upstream.

This entire work (including this document &amp; all associated source code) is
licensed to anyone under the terms of the [GNU General Public License, version
3](https://www.gnu.org/licenses/gpl-3.0.html) (or any higher version, at your
option). For the relevant legal text, see the [LICENSE](./LICENSE) file.
3](https://www.gnu.org/licenses/gpl-3.0.html) (or any later version of the same
license, at the licensee&rsquo;s option). For the relevant legal text, see the
[LICENSE](./LICENSE) file.

[![GNU GPL v3+](https://www.gnu.org/graphics/gplv3-or-later.png
"GNU GPL v3+")](https://www.gnu.org/licenses/gpl-3.0.html)

Versions of shticker\_book\_unwritten prior to 1.0.0 were licensed under the
terms of the [GNU Affero General Public License, version
3](https://www.gnu.org/licenses/agpl-3.0.html) or later.

This work contains ([Rust](https://www.rust-lang.org/)-ified) code from [bsdiff
4.3](http://www.daemonology.net/bsdiff/), which is licensed under a slightly
modified version of [the FreeBSD
Expand All @@ -94,10 +105,10 @@ relevant legal text, see the [LICENSE.bsdiff4](./LICENSE.bsdiff4) file.

The shticker\_book\_unwritten logo is licensed to anyone under the terms of the
[Creative Commons Attribution-ShareAlike license, version
4.0](https://creativecommons.org/licenses/by-sa/4.0/) (or any higher version,
at your option). For the relevant legal text, see
[https://creativecommons.org/licenses/by-sa/4.0/legalcode][cc-by-sa], or the
[img/LICENSE.imgs](img/LICENSE.imgs) file for a plaintext version.
4.0](https://creativecommons.org/licenses/by-sa/4.0/) (or any later version of
the same license, at the licensee&rsquo;s option). For the relevant legal text,
see [https://creativecommons.org/licenses/by-sa/4.0/legalcode][cc-by-sa], or
the [img/LICENSE.imgs](img/LICENSE.imgs) file for a plaintext version.

[![CC BY-SA 4.0+](https://i.creativecommons.org/l/by-sa/4.0/88x31.png
"CC BY-SA 4.0+")](https://creativecommons.org/licenses/by-sa/4.0/)
Expand Down
11 changes: 0 additions & 11 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deny = [
"AFL-2.0",
"AFL-2.1",
"AFL-3.0",
"AGPL-1.0-only",
"AGPL-1.0",
"Apache-1.0",
"Apache-1.1",
"APSL-1.0",
Expand Down
18 changes: 8 additions & 10 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
format_strings = true
imports_indent = "Block"
imports_layout = "HorizontalVertical"
match_arm_blocks = false
match_block_trailing_comma = true
edition = "2018"
fn_args_layout = "Tall"
force_explicit_abi = true
hard_tabs = false
max_width = 79
merge_imports = true
merge_derives = true
newline_style = "Unix"
normalize_comments = false
remove_nested_parens = true
reorder_impl_items = true
struct_field_align_threshold = 24
reorder_imports = true
reorder_modules = true
tab_spaces = 4
use_field_init_shorthand = true
use_small_heuristics = "Default"
use_try_shorthand = true
wrap_comments = false
23 changes: 11 additions & 12 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::{
io::{self, prelude::*},
num::NonZeroUsize,
path::Path,
process,
time,
process, time,
};

const HELP_TEXT: &str = "\
Expand Down Expand Up @@ -95,11 +94,11 @@ pub fn enter_command_mode<'a, P: AsRef<Path>, U: Iterator<Item = &'a str>>(
Some("help") | Some("?") => {
help();
check_children(quiet, &mut children)?;
},
}
Some("about") => {
about();
check_children(quiet, &mut children)?;
},
}
Some("quit") | Some("exit") => {
check_children(quiet, &mut children)?;
if children.is_empty() {
Expand Down Expand Up @@ -137,7 +136,7 @@ pub fn enter_command_mode<'a, P: AsRef<Path>, U: Iterator<Item = &'a str>>(
.read_line(&mut command_buf)
.map_err(Error::StdinError)?;
}
},
}
Some("update") | Some("up") => {
check_children(quiet, &mut children)?;

Expand All @@ -149,7 +148,7 @@ pub fn enter_command_mode<'a, P: AsRef<Path>, U: Iterator<Item = &'a str>>(
println!("Unexpected argument: {}", arg);

continue 'outer;
},
}
}
}

Expand All @@ -173,7 +172,7 @@ pub fn enter_command_mode<'a, P: AsRef<Path>, U: Iterator<Item = &'a str>>(
);
}
}
},
}
Some("login") | Some("play") | Some("launch") => {
login::login(
config,
Expand All @@ -184,26 +183,26 @@ pub fn enter_command_mode<'a, P: AsRef<Path>, U: Iterator<Item = &'a str>>(
&mut children,
)?;
check_children(quiet, &mut children)?;
},
}
Some("instances") | Some("running") => {
check_children(quiet, &mut children)?;
display_instances(&children);
},
}
Some("kill") | Some("close") => {
check_children(quiet, &mut children)?;
kill_instance(quiet, &mut children, argv.next())?;
},
}
Some("accounts") | Some("logins") => {
check_children(quiet, &mut children)?;
display_accounts(config, &children)?;
},
}
_ => {
check_children(quiet, &mut children)?;
println!(
"Unrecognized command. Type help or ? to get a list of \
commands.",
);
},
}
}
}

Expand Down
60 changes: 32 additions & 28 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const DEFAULT_CDN_URI: &str =

#[derive(Deserialize, Serialize, Debug)]
pub struct Config {
pub install_dir: PathBuf,
pub cache_dir: PathBuf,
pub manifest_uri: String,
pub cdn_uri: String,
pub install_dir: PathBuf,
pub cache_dir: PathBuf,
pub manifest_uri: String,
pub cdn_uri: String,
pub store_passwords: bool,
pub accounts: serde_json::Map<String, serde_json::Value>,
pub accounts: serde_json::Map<String, serde_json::Value>,
}

impl Config {
Expand Down Expand Up @@ -80,11 +80,12 @@ pub fn get_config(
match key.as_str() {
"XDG_CONFIG_HOME" => xdg_config_home = value,
"HOME" => home = value,
_ =>
_ => {
if !(home.is_empty() || xdg_config_home.is_empty())
{
break;
},
}
}
}
}

Expand All @@ -107,10 +108,11 @@ pub fn get_config(
for (key, value) in env::vars() {
match key.as_str() {
"APPDATA" => appdata = value,
_ =>
_ => {
if !appdata.is_empty() {
break;
},
}
}
}
}

Expand All @@ -129,10 +131,11 @@ pub fn get_config(
for (key, value) in env::vars() {
match key.as_str() {
"HOME" => home = value,
_ =>
_ => {
if !(home.is_empty()) {
break;
},
}
}
}
}

Expand Down Expand Up @@ -180,12 +183,13 @@ pub fn get_config(
.map_err(Error::SerializeError)?;

Ok((inject_arg_values(new_config), config_path))
},
io::ErrorKind::PermissionDenied =>
}
io::ErrorKind::PermissionDenied => {
Err(Error::PermissionDenied(
format!("opening {:?}", config_path),
ioe,
)),
))
}
_ => Err(Error::UnknownIoError(
format!("opening {:?}", config_path),
ioe,
Expand All @@ -199,16 +203,16 @@ pub fn get_config(

Ok((
Config {
install_dir: PathBuf::from(install_path.ok_or_else(
|| Error::MissingCommandLineArg("--install-dir"),
)?),
cache_dir: PathBuf::from(cache_path.ok_or_else(
|| Error::MissingCommandLineArg("--cache-dir"),
)?),
manifest_uri: DEFAULT_MANIFEST_URI.to_owned(),
cdn_uri: DEFAULT_CDN_URI.to_owned(),
install_dir: PathBuf::from(install_path.ok_or_else(|| {
Error::MissingCommandLineArg("--install-dir")
})?),
cache_dir: PathBuf::from(cache_path.ok_or_else(|| {
Error::MissingCommandLineArg("--cache-dir")
})?),
manifest_uri: DEFAULT_MANIFEST_URI.to_owned(),
cdn_uri: DEFAULT_CDN_URI.to_owned(),
store_passwords: false,
accounts: serde_json::Map::default(),
accounts: serde_json::Map::default(),
},
PathBuf::new(),
))
Expand Down Expand Up @@ -250,18 +254,18 @@ fn prompt_for_config_values<P: AsRef<Path>>(
println!();

return Ok(Config {
install_dir: PathBuf::from(install_dir.trim()),
cache_dir: config_path
install_dir: PathBuf::from(install_dir.trim()),
cache_dir: config_path
.as_ref()
.parent()
.ok_or_else(|| {
Error::BadConfigPath(config_path.as_ref().to_owned())
})?
.join("cache"),
manifest_uri: DEFAULT_MANIFEST_URI.to_owned(),
cdn_uri: DEFAULT_CDN_URI.to_owned(),
manifest_uri: DEFAULT_MANIFEST_URI.to_owned(),
cdn_uri: DEFAULT_CDN_URI.to_owned(),
store_passwords: yes_no_trimmed == "yes",
accounts: serde_json::Map::default(),
accounts: serde_json::Map::default(),
});
}

Expand Down
Loading

0 comments on commit b2cff1e

Please sign in to comment.