Skip to content

Commit 8d57dcf

Browse files
committed
Merge branch 'master' of github.com:sdttttt/gcr
2 parents 6b4aeda + 3034475 commit 8d57dcf

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/arguments.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,24 @@ impl Arguments {
3333
.version(VERSION)
3434
.author(AUTHOR)
3535
.about(DESCRIPTION)
36-
.args(&[Self::push_arg(PUSH_COMMAND), Self::add_arg(ADD_COMMAND)])
36+
.args(&[Self::add_arg(ADD_PARAMS)])
37+
// .args(&[Self::push_arg(PUSH_PARAMS), Self::add_arg(ADD_PARAMS)])
3738
}
3839

39-
fn push_arg(command_name: &str) -> Arg {
40-
Arg::with_name(command_name)
40+
fn push_arg(params_name: &str) -> Arg {
41+
Arg::with_name(params_name)
4142
.short(PUSH_COMMAND_SHORT)
42-
.long(command_name)
43+
.long(PUSH_COMMAND)
4344
.multiple(true)
4445
.required(false)
4546
.help(PUSH_COMMAND_HELP)
4647
.takes_value(true)
4748
}
4849

49-
fn add_arg(command_name: &str) -> Arg {
50-
Arg::with_name(command_name)
50+
fn add_arg(params_name: &str) -> Arg {
51+
Arg::with_name(params_name)
5152
.short(ADD_COMMAND_SHORT)
52-
.long(command_name)
53+
.long(ADD_COMMAND)
5354
.multiple(true)
5455
.required(false)
5556
.help(ADD_COMMAND_HELP)
@@ -58,8 +59,8 @@ impl Arguments {
5859

5960
fn resolve_command(matches: ArgMatches) -> Result<Self, Error> {
6061
let arg: Self;
61-
if matches.is_present(ADD_COMMAND) {
62-
if let Some(files) = matches.values_of(ADD_COMMAND) {
62+
if matches.is_present(ADD_PARAMS) {
63+
if let Some(files) = matches.values_of(ADD_PARAMS) {
6364
let files_vec: Vec<String> = vec_str_to_string(files.collect());
6465
if files_vec.len() == 1 && files_vec[0] == "." {
6566
arg = Self::new(Mode::AddAll, vec![]);
@@ -69,8 +70,8 @@ impl Arguments {
6970
} else {
7071
return Err(Error::from_str(ADD_COMMAND_NO_FILE));
7172
}
72-
} else if matches.is_present(PUSH_COMMAND) {
73-
if let Some(files) = matches.values_of(PUSH_COMMAND) {
73+
} else if matches.is_present(PUSH_PARAMS) {
74+
if let Some(files) = matches.values_of(PUSH_PARAMS) {
7475
let files_vec: Vec<String> = vec_str_to_string(files.collect());
7576
if files_vec.len() == 1 && files_vec[0] == "." {
7677
arg = Self::new(Mode::Auto, vec![]);
@@ -117,6 +118,7 @@ mod tests {
117118
}
118119

119120
#[test]
121+
#[ignore]
120122
fn push_mode() {
121123
let args = quick_command_run(vec!["grc", "--push", "ytsur"]);
122124
match args.command_mode() {
@@ -126,6 +128,7 @@ mod tests {
126128
}
127129

128130
#[test]
131+
#[ignore]
129132
fn auto_mode() {
130133
let args = quick_command_run(vec!["grc", "--push", "."]);
131134
match args.command_mode() {

src/metadata.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ pub enum Mode {
1313
}
1414

1515
pub const ADD_COMMAND: &str = "add";
16+
pub const ADD_PARAMS: &str = "add_file_name";
1617
pub const ADD_COMMAND_SHORT: &str = "a";
17-
// TODO: Fill in the `add` command help
18-
pub const ADD_COMMAND_HELP: &str = "...";
18+
pub const ADD_COMMAND_HELP: &str = "Help you add files before commit. If the parameter is `.`, Then GRC will help you add everything.";
1919
pub const ADD_COMMAND_NO_FILE: &str = "The add command requires parameters.";
2020

2121
pub const PUSH_COMMAND: &str = "push";
22+
pub const PUSH_PARAMS: &str = "push_file_name";
2223
pub const PUSH_COMMAND_SHORT: &str = "p";
2324
// TODO: Fill in the `push` command help
2425
pub const PUSH_COMMAND_HELP: &str = "...";

0 commit comments

Comments
 (0)