Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ path = "src/cli/main.rs"
[dependencies]
clap = "1.5.5"
zip = { version = "0.1.16", default-features = false }
yaml-rust = "0.3.2"
walkdir = "0.1"
toml = "0.1"
2 changes: 2 additions & 0 deletions src/cli/subcmds/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
use cargo;

use super::amethyst_args::{AmethystCmd, AmethystArgs};
use super::is_amethyst_project;
pub struct Cmd;

impl AmethystCmd for Cmd {
/// Compiles the current Amethyst project.
fn execute<I: AmethystArgs>(matches: &I) -> cargo::CmdResult {
try!(is_amethyst_project());
let mut args = vec!["build", "--color=always"];

if matches.is_present("release") {
Expand Down
2 changes: 2 additions & 0 deletions src/cli/subcmds/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
use cargo;

use super::amethyst_args::{AmethystCmd, AmethystArgs};
use super::is_amethyst_project;
pub struct Cmd;

impl AmethystCmd for Cmd {
/// Removes the target directory.
fn execute<I: AmethystArgs>(matches: &I) -> cargo::CmdResult {
try!(is_amethyst_project());
let mut args = vec!["clean", "--color=always"];

if matches.is_present("release") {
Expand Down
2 changes: 2 additions & 0 deletions src/cli/subcmds/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use zip::{ZipWriter, CompressionMethod};
use walkdir::WalkDir;

use super::amethyst_args::{AmethystCmd, AmethystArgs};
use super::is_amethyst_project;

const DEPLOY_DIR: &'static str = "deploy";
const RESOURCES_DIR: &'static str = "resources";
Expand Down Expand Up @@ -156,6 +157,7 @@ pub struct Cmd;
impl AmethystCmd for Cmd {
/// Compresses and deploys the project as a distributable program.
fn execute<I: AmethystArgs>(matches: &I) -> cargo::CmdResult {
try!(is_amethyst_project());
let cargo_args = vec!["release"];
if matches.is_present("clean") {
println!("Cleaning release build directory...");
Expand Down
24 changes: 24 additions & 0 deletions src/cli/subcmds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,27 @@ pub mod deploy;
pub mod module;
pub mod new;
pub mod run;

extern crate yaml_rust;

use std::path::Path;
use self::yaml_rust::YamlLoader;
use std::io::prelude::*;
use std::fs::File;
use cargo::*;

pub fn is_amethyst_project() -> CmdResult {
let config_path = Path::new(&".").join("resources").join("config.yml");
if config_path.exists() {
let mut f = try!(File::open(config_path).map_err(|_| "Couldn't open config.yml"));
let mut s = String::new();
try!(f.read_to_string(&mut s).map_err(|_| "config.yml is not a YAML file."));
let _ = try!(YamlLoader::load_from_str(&s)
.map_err(|_| "config.yml is not a valid YAML file."));

// No docs for what should be inside config.yml yet
Ok(())
} else {
Err(CmdError::Err("The specified project is not an amethyst project.".into()))
}
}
2 changes: 2 additions & 0 deletions src/cli/subcmds/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
use cargo;

use super::amethyst_args::{AmethystCmd, AmethystArgs};
use super::is_amethyst_project;
pub struct Cmd;

impl AmethystCmd for Cmd {
fn execute<I: AmethystArgs>(matches: &I) -> cargo::CmdResult {
try!(is_amethyst_project());
unimplemented!();
}
}
2 changes: 2 additions & 0 deletions src/cli/subcmds/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
use cargo;

use super::amethyst_args::{AmethystCmd, AmethystArgs};
use super::is_amethyst_project;
pub struct Cmd;

impl AmethystCmd for Cmd {
/// Builds and executes the application.
fn execute<I: AmethystArgs>(matches: &I) -> cargo::CmdResult {
try!(is_amethyst_project());
let mut args = vec!["run", "--color=always"];

if matches.is_present("release") {
Expand Down
35 changes: 33 additions & 2 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

# Perform basic integration testing on amethyst_cli.

function prepare() {
ln -s ./target/debug/amethyst .
}

function check_new() {
echo "--- amethyst new"

ln -s ./target/debug/amethyst .
./amethyst new mygame

if [ $? -eq 0 ] &&
Expand All @@ -29,7 +32,6 @@ function check_new() {
function check_build() {
echo "--- amethyst build"

cd mygame
../amethyst build

if [ $? -eq 0 ]; then
Expand Down Expand Up @@ -138,20 +140,49 @@ function check_corrupt_build() {
exit 1
}

function check_noconfig_build() {
echo "--- amethyst build (no config)"

rm resources/config.yml
../amethyst build

if [ $? -ne 0 ]; then
echo "--- Passed!"
echo
return
fi

ls -l
exit 1
}

function clean_up() {
rm -r amethyst mygame
}

clean_up
cargo build
prepare

check_new
cd mygame
check_build
check_run
check_clean
check_deploy

check_noconfig_build
cd ..

clean_up
cargo build
prepare

./amethyst new mygame
cd mygame
check_corrupt_build


echo
echo "All tests pass!"
cd ..
Expand Down