-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fb903e
commit 118611d
Showing
38 changed files
with
740 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,8 @@ | |
.DS_Store | ||
build/ | ||
|
||
# Rust | ||
target | ||
|
||
# Share code style. | ||
!.idea/codeStyleSettings.xml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "mainframer" | ||
version = "2.1.0" | ||
authors = ["Artem Zinnatullin <artem.zinnatullin@gmail.com>", "Artur Dryomov <artur.dryomov@gmail.com>", "Mainframer Developers and Contributors"] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct Args { | ||
pub command: String | ||
} | ||
|
||
impl Args { | ||
pub fn parse(raw_args: Vec<String>) -> Result<Args, String> { | ||
match raw_args.len() { | ||
0 => Err(String::from("Please pass remote command.")), // TODO more user friendly message, for now it's consistent with Bash version. | ||
_ => Ok(Args { | ||
command: raw_args.join(" ").trim().into() | ||
}) | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn parse_command_passed_as_single_parameter() { | ||
let raw_args = vec![String::from("test command")]; | ||
assert_eq!(Args::parse(raw_args), Ok(Args { command: String::from("test command") })); | ||
} | ||
|
||
#[test] | ||
fn parse_empty() { | ||
let raw_args: Vec<String> = vec![]; | ||
assert_eq!(Args::parse(raw_args), Err(String::from("Please pass remote command."))); | ||
} | ||
|
||
#[test] | ||
fn parse_command_passed_as_multiple_parameters() { | ||
let raw_args = vec![String::from("test"), String::from("command")]; | ||
assert_eq!(Args::parse(raw_args), Ok(Args { command: String::from("test command") })); | ||
} | ||
} |
Oops, something went wrong.