Skip to content
Closed
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
12 changes: 0 additions & 12 deletions src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,26 @@ pub fn help_text() -> String {
format!(
"
{}

{}

{}:
reqsh

{}:
{} Show help
{} Show version

{}

{}:
{} <path>
[Headers]

[Body]
::send

{}:
GET, POST, PUT, DELETE

{}:
<key>: <value>
param: <key>=<value>

{}:
raw, json

{}

{}:
base <url>
header <key> <value>
Expand All @@ -50,7 +39,6 @@ pub fn help_text() -> String {
rerun <id>
help
exit

{}
",
"reqsh help".bold().cyan(),
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn shell_loop() {
break;
}
Err(e) => {
println!("{}", e.red().bold());
eprintln!("{}", e.red().bold());
}
},

Expand All @@ -70,7 +70,7 @@ fn shell_loop() {
println!("{}", res);
}
Err(e) => {
println!("{}", e.red().bold());
eprintln!("{}", e.red().bold());
}
}
}
Expand All @@ -82,7 +82,7 @@ fn shell_loop() {
},

Err(e) => {
println!("{}", e.red().bold());
eprintln!("{}", e.red().bold());
}
}
}
Expand All @@ -96,7 +96,7 @@ fn shell_loop() {
}

Err(err) => {
println!("Error: {:?}", err);
eprintln!("Error: {:?}", err);
break;
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ fn collect_input(rl: &mut Editor<ShellHelper, FileHistory>, first_line: String)
}

Err(err) => {
println!("Error: {:?}", err);
eprintln!("Error: {:?}", err);
buffer.clear();
continue;
}
Expand Down
11 changes: 8 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ pub fn parse(input: String) -> Result<Parsed, String> {
let first_line = input.lines().next().unwrap();
let tokens: Vec<&str> = first_line.split_whitespace().collect();

match tokens[0] {
"GET" | "POST" | "PUT" | "DELETE" => {
if tokens.is_empty() {
return Err("No command provided".to_string());
}

let token_match = tokens[0].to_lowercase();
match token_match.as_str() {
"get" | "post" | "put" | "delete" => {
let result = parse_request(input)?;
Ok(Parsed::Request(result))
}
Expand All @@ -27,7 +32,7 @@ pub fn parse(input: String) -> Result<Parsed, String> {

"exit" => Ok(Parsed::Exit),

_ => Err(format!("Reference Error: {} not defined", { tokens[0] })),
_ => Err(format!("Reference Error: {} not defined", tokens[0])),
}
}

Expand Down
Loading