Skip to content

Commit

Permalink
Rename: Environment -> Env
Browse files Browse the repository at this point in the history
type: reform
  • Loading branch information
casey committed Apr 8, 2020
1 parent 7420c91 commit fd06943
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pub(crate) use crate::{

// structs and enums
pub(crate) use crate::{
environment::Environment, error::Error, file_info::FileInfo, hasher::Hasher, info::Info,
metainfo::Metainfo, mode::Mode, opt::Opt, subcommand::Subcommand, torrent::Torrent,
env::Env, error::Error, file_info::FileInfo, hasher::Hasher, info::Info, metainfo::Metainfo,
mode::Mode, opt::Opt, subcommand::Subcommand, torrent::Torrent,
};

// test modules
Expand Down
4 changes: 2 additions & 2 deletions src/environment.rs → src/env.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::common::*;

pub(crate) struct Environment {
pub(crate) struct Env {
args: Vec<String>,
dir: Box<dyn AsRef<Path>>,
pub(crate) err: Box<dyn Write>,
}

impl Environment {
impl Env {
pub(crate) fn main() -> Self {
let dir = match env::current_dir() {
Ok(dir) => dir,
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod testing;
mod bencode;
mod common;
mod consts;
mod environment;
mod env;
mod error;
mod file_info;
mod hasher;
Expand All @@ -46,7 +46,7 @@ mod subcommand;
mod torrent;

fn main() {
if let Err(code) = Environment::main().status() {
if let Err(code) = Env::main().status() {
process::exit(code);
}
}
2 changes: 1 addition & 1 deletion src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) struct Opt {
}

impl Opt {
pub(crate) fn run(self, env: &mut Environment) -> Result<(), Error> {
pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> {
self.subcommand.run(env, self.unstable)
}
}
2 changes: 1 addition & 1 deletion src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) enum Subcommand {
}

impl Subcommand {
pub(crate) fn run(self, env: &mut Environment, unstable: bool) -> Result<(), Error> {
pub(crate) fn run(self, env: &mut Env, unstable: bool) -> Result<(), Error> {
match self {
Self::Torrent(torrent) => torrent.run(env, unstable),
}
Expand Down
4 changes: 2 additions & 2 deletions src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::common::*;

use std::{io::Cursor, iter};

pub(crate) fn environment(iter: impl IntoIterator<Item = impl Into<String>>) -> Environment {
Environment::new(
pub(crate) fn env(iter: impl IntoIterator<Item = impl Into<String>>) -> Env {
Env::new(
tempfile::tempdir().unwrap(),
Cursor::new(Vec::new()),
iter::once(String::from("imdl")).chain(iter.into_iter().map(|item| item.into())),
Expand Down
2 changes: 1 addition & 1 deletion src/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(crate) enum Torrent {
}

impl Torrent {
pub(crate) fn run(self, env: &mut Environment, unstable: bool) -> Result<(), Error> {
pub(crate) fn run(self, env: &mut Env, unstable: bool) -> Result<(), Error> {
match self {
Self::Create(create) => create.run(env),
Self::Stats(stats) => stats.run(env, unstable),
Expand Down
6 changes: 3 additions & 3 deletions src/torrent/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) struct Create {
}

impl Create {
pub(crate) fn run(self, env: &Environment) -> Result<(), Error> {
pub(crate) fn run(self, env: &Env) -> Result<(), Error> {
let input = env.resolve(&self.input);

let mut announce_list = Vec::new();
Expand Down Expand Up @@ -125,8 +125,8 @@ impl Create {
mod tests {
use super::*;

fn environment(args: &[&str]) -> Environment {
testing::environment(["torrent", "create"].iter().chain(args).cloned())
fn environment(args: &[&str]) -> Env {
testing::env(["torrent", "create"].iter().chain(args).cloned())
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/torrent/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) struct Stats {
}

impl Stats {
pub(crate) fn run(self, env: &mut Environment, unstable: bool) -> Result<(), Error> {
pub(crate) fn run(self, env: &mut Env, unstable: bool) -> Result<(), Error> {
if !unstable {
return Err(Error::Unstable {
feature: "torrent stats subcommand",
Expand Down

0 comments on commit fd06943

Please sign in to comment.